Skip to content

Hosted agents: decode SPI event stream and surface nested API errors#1029

Open
logwolvy wants to merge 10 commits into
digitalocean:mainfrom
logwolvy:pr-1021
Open

Hosted agents: decode SPI event stream and surface nested API errors#1029
logwolvy wants to merge 10 commits into
digitalocean:mainfrom
logwolvy:pr-1021

Conversation

@logwolvy

@logwolvy logwolvy commented Jun 8, 2026

Copy link
Copy Markdown
  • HostedAgentEvent now decodes the SPI canonical event envelope the harness-api
    actually emits on the session SSE stream — type / data / timestamp /
    tenant_id (decimal string) with dot-separated event names — via a custom
    UnmarshalJSON, and the HostedAgentEventKind constants use those SPI names
    (run.token_delta, run.started, session.updated, …). Previously it decoded a
    proto-style kind / payload / at / team_id shape that never matched the
    wire, so every streamed event was silently dropped by consumers.
  • ErrorResponse also reads the nested {"error":{"code","message"}} envelope some
    DigitalOcean services (e.g. the hosted-agents harness-api) return, falling back to
    it in Error() so callers see the server's reason instead of a bare status code.

SSharma-10 and others added 10 commits May 27, 2026 21:39
Per PR review, OAuth is out of scope for v0 (GitHub creds come from the
agent spec). Also simplify sessions base path to /v2/agents/sessions.

Co-authored-by: Cursor <cursoragent@cursor.com>
The session SSE stream serializes the SPI canonical event envelope
(type/data/timestamp/tenant_id with dot-separated event names), not the
proto-style kind/payload/at/team_id shape HostedAgentEvent previously
expected. Decode the real wire via a custom UnmarshalJSON and switch the
HostedAgentEventKind constants to the dot-separated SPI names, so streamed
events are mapped onto Kind/Payload/At/TeamID instead of being dropped.

Co-authored-by: Cursor <cursoragent@cursor.com>
Some services (e.g. the hosted-agents harness-api) return errors as
{"error":{"code":...,"message":...}} rather than the top-level
{"message":...} shape. Capture that nested envelope on ErrorResponse and
fall back to its message in Error() so callers see the server's reason
instead of a bare status code.

Co-authored-by: Cursor <cursoragent@cursor.com>
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