docs: add wire-safe serialization section for TypeScript streaming events#693
Conversation
…ents
Document the toJSON() serialization behavior for all TypeScript streaming
events. This includes:
- New 'Wire-Safe Serialization' section in the streaming overview
- Table showing what each event serializes to
- Explanation of excluded fields (agent, tool, cancel, retry)
- Error handling format ({ error: { message?: string } })
- In-process vs wire access patterns
- Updated Express.js example with serialization comments
Related: strands-agents/sdk-typescript#708
- Remove verbose 'How It Works', 'Excluded Fields', 'Error Handling', and 'In-Process Access' subsections - Keep single concise paragraph explaining serialization behavior - Retain events table showing what each event serializes to - Mention excluded fields (agent, tool, cancel, retry) inline Co-authored-by: mkmeral <mkmeral@users.noreply.github.com>
Documentation Preview ReadyYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-cms-693/docs/user-guide/quickstart/overview/ Updated at: 2026-03-25T19:27:11.158Z |
…fields Address review feedback: - Rename 'Wire-Safe Serialization (TypeScript)' to 'Event Serialization' - Wrap in <Tabs> with Python/TypeScript tabs - Lead with what each event keeps during serialization - Move excluded fields mention to secondary position after table - Use 'serialization' language instead of 'wire-safe'
|
add this under streaming events tabs (that already exist) or something, I don't want a tab for python. also that python info is not correct anyway |
…nt types Address review feedback from @mkmeral: - Remove Tabs wrapper and Python tab (info was not correct) - Downgrade to ### subsection under Event Types (same level as Lifecycle Events, Model Stream Events, etc.) - TypeScript serialization content stays as-is, directly under heading
|
Done in
Net change: -11 lines, +1 line. |
…aming-serialization
|
Merged Root cause: The in Fix: Merged upstream CI should be green now. @mkmeral |
Updates Event Serialization section for sdk-typescript PR #741: - Put Event Serialization under Python/TypeScript tabs - Add multi-agent event serialization table (10 events from PR #741) - Add A2A event serialization table (2 events from PR #741) - Add Python tab explaining event filtering approach - Update excluded fields list to include orchestrator and state - Note Error object serialization format
Replace the three comprehensive tables (agent events, multi-agent events, A2A events) in the TypeScript serialization tab with prose that explains the behavior, the key differences during serialization, and mentions a few examples of filtered/included fields without an exhaustive listing. Python tab remains unchanged.
Show what an event looks like in-process (with agent reference) versus what JSON.stringify produces (compact wire-safe output). Covers text deltas, lifecycle events, and result events.
Removed commented-out code regarding lifecycle and result events.
|
/strands review |
agent-of-mkmeral
left a comment
There was a problem hiding this comment.
Review — /strands review
Overall: Looks good to me ✅ — clean addition, well-structured, all previous feedback addressed.
Summary
| Aspect | Status |
|---|---|
| CI | ✅ Green |
| All 3 review threads | ✅ Resolved |
| Placement | ✅ ### Event Serialization under Event Types, before Quick Examples |
| Consistency | ✅ Uses <Tabs> pattern matching rest of page |
| Files changed | 2 files, +81/-2 lines |
What's Good
-
TypeScript tab — Clear explanation of
toJSON()mechanics. The code example with inline comments showing in-process vs serialized output is really instructive. Leads with what each event keeps (per earlier feedback). -
Python tab — The
filter_event()helper is practical and actionable. Since Python events are plain dicts with no built-in serialization filter, showing a concrete pattern users can adapt is the right call. -
async-iterators.ts — The 3-line comment on the
JSON.stringify(event)call adds context without being noisy.
Minor Nits (non-blocking)
-
"wire-safe" in async-iterators.ts comment — The code comment says
"Events automatically serialize to compact, wire-safe JSON via toJSON()". Earlier feedback asked to prefer "serialization" language over "wire" language. Consider:// Events automatically serialize to compact JSON via toJSON().(Drop "wire-safe" to stay consistent with the main docs section title "Event Serialization".)
-
Python tab existence — Previous feedback said "I don't want a tab for python". The content is completely rewritten now (the incorrect info is gone, replaced with a useful
filter_eventpattern), so this is likely fine — but flagging in case @mkmeral still prefers no Python tab here.
Neither nit is blocking. PR is ready for maintainer approval.
Description
Documents the
toJSON()serialization behavior for all TypeScript streaming events. When events are sent over the wire (SSE, WebSockets, HTTP responses), thetoJSON()method ensures compact output (~100-200 bytes) instead of serializing the entireAgentinstance (~54KB+ per event).Changes
Streaming Overview (
index.mdx): Added new "Wire-Safe Serialization (TypeScript)" section with:toJSON()works withJSON.stringify()agent,tool,cancel,retry){ error: { message?: string } })Express.js example (
async-iterators.ts): Added comments explaining the automatic wire-safe serialization behaviorRelated Issues
toJSON()to all streaming eventsType of Change
Checklist
npm run dev