feat(events)!: make session id explicit in event stream#61
Merged
Conversation
Let callers pass the session id into wire_event_queue instead of inferring it from manifest ordering, and give SESSION_START/SESSION_END a stable, predictable shape.
BREAKING CHANGE: first_session_id() removed; wire_event_queue no longer auto-derives the session id. SESSION_START data is now {session_id, manifest} and AGENT_START/agent-stop payloads drop the "type" field.
- Update AnsiRenderer to access manifest from event.data["manifest"] instead of directly from event.data - Aligns with explicit session id structure in event stream
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.
Description
Give callers explicit control over the session id in the event stream instead of inferring it from manifest ordering. The
SESSION_STARTpayload is restructured into a stable envelope so consumers can access both the session id and the manifest topology in a predictable way.close()gains an optionaldataparameter so end-of-stream metadata can be attached at call time rather than being fixed at wiring time. The redundant"type": "agent"field is removed fromAGENT_STARTand agent-stop payloads since it duplicated information already on the event envelope.Related Issues
N/A
Type of Change
YAML / API Impact
Yes — breaking changes to the public Python API and the event stream contract.
ResolvedConfig.wire_event_queue()now accepts an explicitsession_id: str | None = Nonekeyword argument. Previously the session id was derived automatically from the first session manager found in the manifest. Callers that relied on implicit derivation now receiveNoneunless they passsession_idexplicitly.first_session_id(manifest)has been removed fromstrands_compose.manifest. Any code importing it will break.SESSION_STARTeventdatashape changed from the rawSessionManifest.model_dump()dict to{"session_id": <str | null>, "manifest": <SessionManifest dict>}. Consumers readingevent.data["agents"]directly must update toevent.data["manifest"]["agents"].EventQueue.close()now accepts an optionaldata: dictparameter.AGENT_STARTandAGENT_COMPLETEevent payloads no longer include the"type": "agent"field.Config YAML schema is unchanged.
Testing
How have you tested the change?
uv run just check(lint + type check)uv run just testfor overall testingexamples/still workChecklist