Skip to content

Stop a finished call from keeping a thread busy forever - #200

Open
splitbrain-bot wants to merge 1 commit into
splitbrain:mainfrom
splitbrain-bot:stuck-turn-state
Open

splitbrain-bot wants to merge 1 commit into
splitbrain:mainfrom
splitbrain-bot:stuck-turn-state

Conversation

@splitbrain-bot

Copy link
Copy Markdown

A thread stayed busy without end: the stop button and the spinner stayed in every browser, also after a reload and on a device that opened the thread for the first time.

Cause: Activity keeps a thread speaking while a foreground tool call is open. It opened a call on every tool_call_update that had no final status. The Claude adapter also sends updates without any status for a call that is over, such as the terminal_exit of a background command or the report of a PostToolUse hook. Such an update after the end of the turn opened the call again. No final status followed, so the quiet timer started again every AGENT_QUIET_SECONDS without end.

Changes:

  • An update without a status opens no call. Only a tool_call, or a tool_call_update with a status that is not final, opens one.
  • The return of the last prompt in flight on a thread ends the turn. This also closes a call that got no final status, for example the call of a sub agent that failed.

Limits:

  • A late update without a status still marks the thread as speaking for AGENT_QUIET_SECONDS.
  • A turn without a prompt, such as one that a task report starts, has no prompt end. A call with a status that such a turn leaves open is closed only by the end-of-cycle update of the adapter.

Tests:

  • activity.test.ts checks that an update without a status does not open a finished call again, that it leaves an open call open, and that the end of the prompt ends a turn with an open call.
  • upstream.test.ts checks that a prompt that returns ends a turn that left a tool call open, and that the browser is told.

A thread stayed busy without end when a tool call was open and no final status came for it. The gateway opened a
call on every tool call update that had no final status. The adapter also sends updates without any status for a
call that is over, such as the exit of the terminal of a background command or the report of a PostToolUse hook.
Such an update after the end of the turn opened the call again, and nothing closed it. The stop button then stayed
in every browser until the next turn ended.

An update without a status now opens no call. The return of the last prompt on a thread now ends the turn, which
also closes a call that got no final status.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants