feat: serialize AgentEvent and StreamDelta for wire transport#72
Merged
Conversation
AgentEvent and StreamDelta now derive Serialize, Deserialize, and
PartialEq. The wire format is internally tagged camelCase JSON
({"type":"toolExecutionEnd","toolCallId":...,"isError":false})
and is a frozen public contract guarded by snapshot tests, so external
frontends (websocket fanout servers, TS clients, JSONL pipes) can
consume the event stream directly.
Additive only: no variant, field, or signature changes. serde floor
bumped to 1.0.186 for rename_all_fields.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review findings from PR #72: - Normalize the five remaining snake_case payload fields to camelCase (usage.cacheRead/cacheWrite/totalTokens, errorMessage, providerMetadata) with serde aliases so pre-0.13 session files still load. The wire contract is now uniformly camelCase. - Freeze tags via exhaustive match (no wildcard): a new AgentEvent or StreamDelta variant now fails to compile in the test file until its wire tag is pinned. - Exact-JSON snapshot of a full messageEnd payload (all Content variants, non-default Usage, errorMessage) — freezes the nested shape that carries most wire bytes. - Forward-compat tests: unknown fields ignored, unknown/wrong-case tags are clean Errs; legacy snake_case payload load test. - Fix docs: MessageUpdate.message is a placeholder during streaming; clients accumulate deltas and resync at MessageEnd (the cumulative claim was false). - serde floor corrected to 1.0.181 (actual rename_all_fields release). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
Applied review fixes from the two-agent pass:
393 tests green, clippy |
This was referenced Jul 14, 2026
Merged
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.
Summary
AgentEventandStreamDeltanow deriveSerialize,Deserialize, andPartialEq{"type":"toolExecutionEnd","toolCallId":"...","isError":false}— declared a frozen public contract in the rustdoc and guarded by snapshot tests (all 12 variant tags + camelCase field names)rename_all_fields; released Aug 2023)MessageUpdatecarries the cumulative message)This is the only yoagent change needed to support external streaming frontends (websocket fanout, TypeScript clients, JSONL pipes) — first step of the yoyo-serve track.
Additive only: no variant, field, or signature changes; existing sinks that match/clone/Debug events are untouched.
Test plan
AgentEvent+StreamDeltavariant"type"tags frozen{"type":"agentStart"}) + inbound raw-JSON parsecargo test --all-features— 393 tests green; clippy-Dwarningsclean🤖 Generated with Claude Code