Skip to content

fix: allow agent-reported final states, add SSE reconnection#22286

Merged
mafredri merged 2 commits intomainfrom
fix/task-state-reporting
Feb 24, 2026
Merged

fix: allow agent-reported final states, add SSE reconnection#22286
mafredri merged 2 commits intomainfrom
fix/task-state-reporting

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Feb 24, 2026

When AgentAPI is configured, WithTaskReporter unconditionally overrides all self-reported states to working. The intent was to distrust the agent's idle and rely on the screen watcher, but the override also blocks failure and complete, which only the agent can produce (the screen watcher only knows running/stable). Tasks get stuck as working or null forever.

Now only idle is overridden to working; failure, complete, and working pass through as-is.

Also:

  • Remove misplaced unconditional "Failed to watch screen events" log that fired on every startup
  • Add SSE reconnection with exponential backoff (1s-30s) in startWatcher so it recovers from dropped connections instead of dying silently
  • Add complete to the coder_report_task tool enum, which the coder/claude-code registry module already instructs agents to use but was missing from the schema

Refs coder/internal#1350

@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
@mafredri mafredri force-pushed the fix/task-state-reporting branch from 33d031c to ad0997c Compare February 24, 2026 14:40
@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
@mafredri mafredri force-pushed the fix/task-state-reporting branch from ad0997c to 0ff38e7 Compare February 24, 2026 14:59
@mafredri mafredri force-pushed the fix/task-state-reporting branch 10 times, most recently from 891d68f to 9293bee Compare February 24, 2026 17:04
…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 force-pushed the fix/task-state-reporting branch from 9293bee to 5cd2b74 Compare February 24, 2026 18:15
@mafredri mafredri merged commit 947b390 into main Feb 24, 2026
27 checks passed
@mafredri mafredri deleted the fix/task-state-reporting branch February 24, 2026 18:28
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants