Hosted agents: decode SPI event stream and surface nested API errors#1029
Open
logwolvy wants to merge 10 commits into
Open
Hosted agents: decode SPI event stream and surface nested API errors#1029logwolvy wants to merge 10 commits into
logwolvy wants to merge 10 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HostedAgentEventnow decodes the SPI canonical event envelope the harness-apiactually emits on the session SSE stream —
type/data/timestamp/tenant_id(decimal string) with dot-separated event names — via a customUnmarshalJSON, and theHostedAgentEventKindconstants use those SPI names(
run.token_delta,run.started,session.updated, …). Previously it decoded aproto-style
kind/payload/at/team_idshape that never matched thewire, so every streamed event was silently dropped by consumers.
ErrorResponsealso reads the nested{"error":{"code","message"}}envelope someDigitalOcean 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.