agent+acp: preserve session on retriable agent errors#544
Merged
Conversation
cd48954 to
36f2996
Compare
Don't invalidate the session when the agent returns AgentError. The agent caught the problem (e.g. LLM returned stop=tool_use with zero tool_calls) and the session is still usable. The existing requeue mechanism retries on the same session with full context intact. Previously, any prompt error invalidated the session, forcing a fresh session/new on retry — new MCP servers, lost history, lost todo state. Now AgentError is distinguished from transport/protocol errors that genuinely corrupt session state.
36f2996 to
248338c
Compare
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Don't invalidate the session when the agent returns an application error (
AgentError). The agent caught the problem before the session became unusable — the existing requeue mechanism retries on the same session with full context intact.What
One change in
pool.rs: skipagent.state.invalidate(&source)when the error isAcpError::AgentError.Why
Transient LLM glitches (e.g.
stop=tool_usewith zero tool calls) cause sprout-agent to return a JSON-RPC application error. The session is still healthy — MCP servers are running, history is valid, the stdio pipe is intact. Previously the harness invalidated the session on any prompt error, forcing a freshsession/newon retry: new MCP server processes, lost history, lost todo state.Now the harness distinguishes retriable application errors from session-corrupting transport/protocol errors. The session stays alive and the batch retries on the same session via the existing requeue + backoff mechanism.