MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestTaskModelErrors

Function TestTaskModelErrors

internal/llmloop/task_test.go:219–247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestTaskModelErrors(t *testing.T) {
220 for _, grace := range []bool{false, true} {
221 t.Run(strconv.FormatBool(grace), func(t *testing.T) {
222 task := testTask()
223 task.MaxRounds = 1
224 requests := 0
225 client := taskClient(func(context.Context, llm.ChatRequest) (*llm.ChatResponse, error) {
226 requests++
227 if grace && requests == 1 {
228 return testTaskResponse("read_test_data", `{}`), nil
229 }
230 return nil, errors.New("model unavailable")
231 })
232 history := session.New(t.TempDir(), "main", "fake", session.SessionOptions{})
233 runner := NewRunner(Deps{LLMClient: client, Session: history}, task)
234 result, err := runner.Run(context.Background(), taskMessages(), "data")
235 if result.Completed || (err == nil) != grace {
236 t.Fatalf("Run = %+v, %v", result, err)
237 }
238 if grace && result.StopReason != StopMaxRounds {
239 t.Fatalf("grace stop = %v", result.StopReason)
240 }
241 records := history.GetOrCreateFileSession("data").TaskRecords[session.MainTask]
242 if records[len(records)-1].Error != "model unavailable" {
243 t.Fatal("model failure was not recorded")
244 }
245 })
246 }
247}
248
249func TestTaskGraceOutcomes(t *testing.T) {
250 for _, scenario := range []string{"no_calls", "failed", "mixed", "no_tools", "cancelled"} {

Callers

nothing calls this directly

Calls 9

RunMethod · 0.95
NewFunction · 0.92
testTaskFunction · 0.85
taskClientFuncType · 0.85
testTaskResponseFunction · 0.85
taskMessagesFunction · 0.85
NewRunnerFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected