Skip to content

feat(agent): capture full Reference content and ChatStartedPayload fields - #566

Open
hogan-yuan wants to merge 2 commits into
mainfrom
feat/agent-reference-content
Open

feat(agent): capture full Reference content and ChatStartedPayload fields#566
hogan-yuan wants to merge 2 commits into
mainfrom
feat/agent-reference-content

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

What

Audited the agent SSE wire against the SDK types (using a recorded real stream) and closed the two places the SDK dropped data the server actually sends.

Reference — was lossy

The real reference nests the human-readable fields under a content object and carries type/id/original_index at the top level:

{"type":"NewsArticle","id":"295354885","index":1,"original_index":10,
 "content":{"source":"","description":"","published_at":"","source_url":"","source_logo":"","kind":"","title":""}}

The SDK modeled only a flat {index,title,url} — so title/url came back empty for real references and source/description/published_at/… were lost entirely. Add original_index, ref_type (wire "type"), id, and content (raw JSON — the shape varies by ref_type). Fixes references wherever they appear: ConversationResponse.references and the message / node_tool_use_finished / workflow_finished outputs.

ChatStartedPayload

Add chat_id / error / error_message (present on the wire, mirroring ChatFinishedPayload).

Bindings

Mirrored across Python, Node.js, Java, C (+ rust core); the C header is regenerated by cbindgen. content is surfaced as raw JSON — serde_json::Value in Rust/Python/Node, a JSON string in C (content_json) and Java (getContent()), following the existing NodeToolUseOutputs.data precedent. Each binding crate builds clean; rust core tests cover the nested-content and flat-shape references.

Why

Downstream (longbridge-terminal) renders a References footer and emits references in --format json; going through the SDK's lossy Reference silently blanked both. This restores fidelity. Companion PR: longbridge/openapi-go#113.

…elds

Audited the agent SSE wire against the SDK types and closed the gaps
where the SDK dropped data the server actually sends:

- Reference: the real payload nests the human-readable fields under a
  `content` object (source, description, published_at, source_url,
  source_logo, kind, …) and carries `type`/`id`/`original_index` at the
  top level. The SDK modeled only a flat {index,title,url}, so title/url
  came back empty for real references and everything else was lost. Add
  original_index, ref_type (wire "type"), id, and content (raw JSON,
  since the field set varies by ref_type). This fixes references
  everywhere they appear: ConversationResponse.references, and the
  message / node_tool_use_finished / workflow_finished outputs.
- ChatStartedPayload: add chat_id / error / error_message (present on
  the wire, mirroring ChatFinishedPayload).

Mirrored across every binding (Python, Node.js, Java, C); the C header
is regenerated by cbindgen. content is surfaced as raw JSON — a
serde_json::Value in Rust/Python/Node, a JSON string in C
(content_json) and Java (getContent), following the existing
NodeToolUseOutputs.data precedent.
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