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

Function TestClassifyMainLoopStop

internal/agent/coverage_test.go:1064–1091  ·  view source on GitHub ↗

classifyMainLoopStop keeps the unknown class for the empty-round and compression exits, but each reason must name its trigger: in --format json runs the manifest reason is the only stop diagnostic that leaves the runner, so the three non-budget stops must not collapse into one string.

(t *testing.T)

Source from the content-addressed store, hash-verified

1062// runs the manifest reason is the only stop diagnostic that leaves the runner,
1063// so the three non-budget stops must not collapse into one string.
1064func TestClassifyMainLoopStop(t *testing.T) {
1065 reasons := make(map[string]llmloop.MainLoopStop)
1066 for _, tc := range []struct {
1067 name string
1068 stop llmloop.MainLoopStop
1069 wantClass session.FailureClass
1070 wantReason string
1071 }{
1072 {"max_rounds", llmloop.StopMaxRounds, session.FailureBudget, "reached the maximum tool-request rounds without finishing"},
1073 {"empty_rounds", llmloop.StopEmptyRounds, session.FailureUnknown, "stopped after repeated rounds without a usable tool result"},
1074 {"compression", llmloop.StopCompression, session.FailureUnknown, "stopped because context compression exceeded its threshold"},
1075 {"none", llmloop.StopNone, session.FailureUnknown, "main task stopped before completing"},
1076 } {
1077 t.Run(tc.name, func(t *testing.T) {
1078 class, reason := classifyMainLoopStop(tc.stop)
1079 if class != tc.wantClass {
1080 t.Errorf("class = %q, want %q", class, tc.wantClass)
1081 }
1082 if reason != tc.wantReason {
1083 t.Errorf("reason = %q, want %q", reason, tc.wantReason)
1084 }
1085 if prev, dup := reasons[reason]; dup {
1086 t.Errorf("reason %q is shared by %v and %v; stops must stay distinguishable", reason, prev, tc.stop)
1087 }
1088 reasons[reason] = tc.stop
1089 })
1090 }
1091}

Callers

nothing calls this directly

Calls 2

classifyMainLoopStopFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected