Anthropic::Sessions
Helpers for Managed Agents session event streams.
Class methods
Fold Managed Agents session/preview streaming events into a buffered
agent.message snapshot (returned as a JSON::Any object).
Mirrors the TypeScript/Python accumulate_managed_agents_event helper.
Pass the previously accumulated snapshot (or nil) plus the latest event,
and receive the updated snapshot (or nil for non-agent.message events
that don't affect the accumulator).
event_startwithevent.type == "agent.message"opens a fresh snapshot{id, type: "agent.message", content: [], processed_at: ""}.event_deltafoldsdelta.contentintocontent[delta.index ?? 0].agent.message(buffered final) replaces the snapshot.- All other event types are no-ops returning
accumulatedunchanged.
Returns nil if a delta arrives before its event_start (the caller
should drop stray deltas), per the official manual-deltas example.