Problem: During subturn context limit or truncation recoveries, the recovery loops repeatedly called `runAgentLoop` with the same or modified `UserMessage`. Because `runAgentLoop` unconditionally adds the `UserMessage` to the session history, this resulted in: 1. Duplicate User Messages polluting the history upon `context_length_exceeded` retries. 2. The possibility of injecting empty User Messages if `opts.UserMessage` was artificially blanked out to work around the duplication. 3. Messy or duplicate entries during `finish_reason="truncated"` recovery injections. Solution: - Introduce `SkipAddUserMessage` boolean to `processOptions` to explicitly control whether the agent loop should write the user prompt to history. - Add an explicit `opts.UserMessage != ""` check in `runAgentLoop` to prevent polluting history with empty message content. - In `subturn.go`'s recovery loop, set `SkipAddUserMessage: contextRetryCount > 0` to skip writing the user message on context |
||
|---|---|---|
| .. | ||
| bm25.go | ||
| bm25_test.go | ||
| context.go | ||
| context_test.go | ||
| download.go | ||
| http_client.go | ||
| http_client_test.go | ||
| http_retry.go | ||
| http_retry_test.go | ||
| media.go | ||
| skills.go | ||
| string.go | ||
| string_test.go | ||
| zip.go | ||