fix: allow agent-reported final states, add SSE reconnection by mafredri · Pull Request #22286 · coder/coder

johnstcn

@mafredri mafredri changed the title fix(cli/exp_mcp): trust terminal states from agent, add SSE reconnection fix(cli/exp_mcp): allow agent-reported final states, add SSE reconnection

Feb 24, 2026

johnstcn

@mafredri mafredri changed the title fix(cli/exp_mcp): allow agent-reported final states, add SSE reconnection fix(cli): allow agent-reported final states, add SSE reconnection

Feb 24, 2026

@mafredri mafredri changed the title fix(cli): allow agent-reported final states, add SSE reconnection fix: allow agent-reported final states, add SSE reconnection

Feb 24, 2026

johnstcn

…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.

@mafredri mafredri deleted the fix/task-state-reporting branch

February 24, 2026 18:28