Reason is the safe, human-facing sentence for a stop, and the single source of truth for it: the diff-review manifest reason and the scan subtask warning both render this string, so the same stop can never read differently in the two commands' output. Each return is a static literal — never error te
()
| 261 | // new constant announces itself in the artifact rather than hiding behind a |
| 262 | // message that says nothing. |
| 263 | func (s MainLoopStop) Reason() string { |
| 264 | switch s { |
| 265 | case StopNone: |
| 266 | return "main task stopped before completing" |
| 267 | case StopMaxRounds: |
| 268 | return "reached the maximum tool-request rounds without finishing" |
| 269 | case StopEmptyRounds: |
| 270 | return "stopped after repeated rounds without a usable tool result" |
| 271 | case StopCompression: |
| 272 | return "stopped because context compression exceeded its threshold" |
| 273 | default: |
| 274 | return fmt.Sprintf("main task stopped for an unrecognized reason (stop=%d)", int(s)) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // RunPerFile drives the main LLM conversation loop for a single file. |
| 279 | // It sends messages with the configured tool definitions, executes any |
no outgoing calls