Skip to content

The chat's agent starts when the chat is first used, and ends after the last editor - #268

Merged
endrix merged 1 commit into
mainfrom
feat/chat-agent-on-demand
Dec 2, 2026
Merged

endrix merged 1 commit into
mainfrom
feat/chat-agent-on-demand

Conversation

@endrix

@endrix endrix commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Each editor's chat panel started its profile's agent at its handshake, used or not: a product with two profiles kept two agents (an ACP process and its server each) from its first editors until the window closed.

  • The agent now starts at the chat's first use: a message sent, a chat made, opened or deleted, or Diagnose Connection. Until then the panel reads "Not started". While a start is under way every panel reads "Connecting…", a failed start is reported to every panel, and the 30 s connect watchdog runs from the start.
  • Once the profile's last editor has closed and no turn has run for 30 s, the agent is stopped. The next use starts it again, and each chat is loaded into it again. An editor opened within the 30 s keeps the agent running. If a return from the agent's CLI or a change of agent is under way, the stop waits for it to end.
  • DiagramChatConfig.agentStart: 'eager' (the toolkit's chat.agentStart) keeps the old start and lifetime. The member is optional; the API version is unchanged.
  • Measured with opencode 2.4.0 (scratch home, no prompt sent): ending the ACP process ends its server too, within about a second after SIGTERM and half a second after SIGKILL. So stopping that agent leaves no process behind. Other agents were not tried.

Known edges:

  • A new start does not wait for the old process to end. If the chat is used again within the stop's few seconds, an agent that holds a session until its process ends may fail that chat's reload once.
  • A turn waiting on a permission answer with no editor open has no timeout, so that agent is never stopped (pre-existing).
  • A product whose page was built from an older client shows "Disconnected" with the reason until it is rebuilt.

Checked by unit tests, the six typechecks, the neutrality gate and the build. Not seen in a live VS Code.

https://claude.ai/code/session_01EToj6PHh9rgzTMK9sxo4zA

Each editor's chat panel started its profile's agent at its handshake,
used or not: a product with two profiles kept two agents (an ACP
process and its server each) from its first editors until the window
closed.

The agent now starts at the chat's first use: a message sent, a chat
made, opened or deleted, or Diagnose Connection. Until then the panel
reads "Not started". While a start is under way every panel reads
"Connecting...", a failed start is reported to every panel, and the
30 s connect watchdog runs from the start.

Once the profile's last editor has closed and no turn has run for 30 s,
the agent is stopped. The next use starts it again and each chat is
loaded into it again. An editor opened within the 30 s keeps the agent
running. If a return from the agent's CLI or a change of agent is under
way, the stop waits for it to end.

DiagramChatConfig.agentStart: 'eager' (the toolkit's chat.agentStart)
keeps the old start and lifetime. The member is optional; the API
version is unchanged.

Measured with opencode 2.4.0 (scratch home, no prompt sent): ending the
ACP process ends its server too, within about a second after SIGTERM
and half a second after SIGKILL. Other agents were not tried.

Known edges: a new start does not wait for the old process to end; a
turn waiting on a permission answer with no editor open has no timeout,
so that agent is never stopped (pre-existing); a product whose page was
built from an older client shows "Disconnected" with the reason until
it is rebuilt.

Checked by unit tests, the six typechecks, the neutrality gate and the
build. Not seen in a live VS Code.

Claude-Session: https://claude.ai/code/session_01EToj6PHh9rgzTMK9sxo4zA
@endrix
endrix merged commit 486df1b into main Dec 2, 2026
1 check passed
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.

1 participant