Skip to content

fix(v2): decouple session updates from prompt completion - #280

Merged
benbrandt merged 1 commit into
mainfrom
fix/v2-session-scoped-updates
Oct 14, 2026
Merged

benbrandt merged 1 commit into
mainfrom
fix/v2-session-scoped-updates

Conversation

@benbrandt

Copy link
Copy Markdown
Member

Summary

ACP v2 prompt responses acknowledge insertion of a user message, while state_update reports session-scoped foreground work. The SDK previously treated any idle update as completion of all pending prompts, even if a prompt had not been inserted yet.

  • Remove prompt-completion tracking, overlap detection, and prompt-based queue resets from experimental v2 active sessions.
  • Return every idle update as a session-scoped stop message, independent of prompt requests.
  • Keep prompt rejection on the prompt response promise instead of injecting it into the session update queue.
  • Replace readText() with readTextUntilIdle() to make its session-scoped collection boundary explicit.
  • Allow optional abort signals for session reads without cancelling agent work.
  • Adapt existing coverage for idle before insertion, overlapping requests with rejection, message replacement, and queued output across submissions.

Experimental v2 API migration

Replace session.readText() with session.readTextUntilIdle(). The new helper consumes queued session output until the next idle notification. It does not attribute that output to a particular prompt, skip earlier updates, or guarantee that a submitted message has been processed. Use one reader at a time.

session.prompt() still returns the insertion receipt and messageId. Handle request rejection through that promise; session readers continue independently.

V1 and the protocol wire schema are unchanged. No prompt or turn correlation fields are added to state_update.

Validation

  • npm run check passed: generated-source checks, lint, formatting, spelling, TypeScript build, full test suite, and TypeDoc verification.
  • Direct validation against the built v2 API confirmed reader abort preserves subsequent updates and disposal/connection close reject pending readers.
  • git diff --check passed.

@benbrandt
benbrandt merged commit 0154528 into main Oct 14, 2026
6 checks passed
@benbrandt
benbrandt deleted the fix/v2-session-scoped-updates branch October 14, 2026 11:24
This was referenced Oct 19, 2026
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