fix: allow agent-reported final states, add SSE reconnection#22286
Merged
fix: allow agent-reported final states, add SSE reconnection#22286
Conversation
johnstcn
reviewed
Feb 24, 2026
33d031c to
ad0997c
Compare
johnstcn
approved these changes
Feb 24, 2026
ad0997c to
0ff38e7
Compare
johnstcn
approved these changes
Feb 24, 2026
891d68f to
9293bee
Compare
…tion Previously WithTaskReporter unconditionally overrode all self-reported states to "working" when AgentAPI was enabled. This blocked final states (failure, complete) that only the agent can produce, since the screen watcher cannot detect them. Now only idle is overridden to working; failure, complete, and working pass through as-is. Also remove a misplaced unconditional log line that printed "Failed to watch screen events" on every startup, and add SSE reconnection with exponential backoff in startWatcher so it recovers from dropped connections.
The coder/claude-code registry module instructs agents to report "complete" when finished, but the tool schema omitted it from the enum. Add it alongside working, idle, and failure.
9293bee to
5cd2b74
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When AgentAPI is configured,
WithTaskReporterunconditionally overrides all self-reported states toworking. The intent was to distrust the agent'sidleand rely on the screen watcher, but the override also blocksfailureandcomplete, which only the agent can produce (the screen watcher only knowsrunning/stable). Tasks get stuck asworkingornullforever.Now only
idleis overridden toworking;failure,complete, andworkingpass through as-is.Also:
"Failed to watch screen events"log that fired on every startupstartWatcherso it recovers from dropped connections instead of dying silentlycompleteto thecoder_report_tasktool enum, which thecoder/claude-coderegistry module already instructs agents to use but was missing from the schemaRefs coder/internal#1350