Skip to content

feat(acp): complete prompts asynchronously over SSE - #308

Open
RGHenderson wants to merge 3 commits into
rivet-dev:mainfrom
RGHenderson:feat/acp-async-request-sse
Open

RGHenderson wants to merge 3 commits into
rivet-dev:mainfrom
RGHenderson:feat/acp-async-request-sse

Conversation

@RGHenderson

Copy link
Copy Markdown

Summary

  • return 202 Accepted once session/prompt has been written to the agent
  • deliver the eventual JSON-RPC result, timeout, or process-exit error over the existing SSE stream
  • preserve synchronous handling for short requests and immediate HTTP errors before acceptance
  • document and test the updated transport contract

Motivation

Long-running prompt POSTs currently remain open for the entire agent turn. Their success therefore depends on every client and intermediary allowing sufficiently long response-header timeouts, even though the client already maintains an SSE stream capable of carrying correlated JSON-RPC responses.

Rationale

session/prompt is the long-running operation that needs asynchronous HTTP acceptance. Registering its request ID before writing to the agent preserves response correlation and ring-buffer replay. Returning 202 only after the stdin write succeeds keeps validation and write failures synchronous, while detached timeout and process-exit handling ensure every accepted request still receives a terminal JSON-RPC envelope.

Other requests keep their existing 200 response-body behavior, and notifications retain their existing 202 behavior. This PR is independent of the request-scoped client reliability fix in #306.

Closes #305.

Test plan

  • cargo fmt --all -- --check
  • cargo check -p acp-http-adapter -p sandbox-agent
  • cargo test -p acp-http-adapter
  • pnpm --filter acp-http-client typecheck
  • rebuilt sandbox-agent and ran pnpm --filter acp-http-client test
  • Docker-backed acp_round_trip_and_replay in CI (the local in-process image build stalled before creating a container)

Acknowledge long-running prompt requests after the agent accepts them, then deliver their correlated result, timeout, or process-exit error through the existing SSE stream.
Keep the generated ACP response update scoped without dropping schemas that remain part of the checked-in API contract.
Close replay and publication races, reconnect failed event streams, preserve error diagnostics, and guarantee one terminal response for timeout, exit, or shutdown.
@RGHenderson
RGHenderson marked this pull request as ready for review July 21, 2026 09:33
@RGHenderson

Copy link
Copy Markdown
Author

@NathanFlurry WDYT? Left some open questions in the attached issue.

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.

Allow long-running ACP requests to complete asynchronously over SSE

1 participant