Settle Session creation streams like the official service - #50
Merged
Merged
Conversation
Close fresh creation streams right after the first settling idle or failed event, with a same-snapshot fallback for settlements that record no event; end same-key stream retries immediately; send the committed JSON 201 projection as the created snapshot; carry Turn usage on terminal Turn events; and record new Turns as turn.created, user items, session.in_progress, turn.in_progress. Squashed from the reviewed branch head 80f7a1703aa6021e7ff77545d7ce2dfaf5e82305 onto main 4f3822a.
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.
A pinned-SDK loop over
client.beta.agents.sessions.create(..., stream=True)never ended on Core, because the creation stream stayed open after the Session settled. The official service closes it at the first settling idle. This batch aligns creation-stream settlement, the created snapshot, terminal Turn usage and Turn start order with owned official observations. The pinned baseline is unchanged (SDK 3.13.0 / d7c41ef /agents=v1).Behavior
agent.session.idlerecorded when a root Turn ends or a reservation stops being pending, or anyagent.session.failed. Events after it in the same batch are not sent.requires_action, function results and resumes.self_hostedwithout input) closes right aftercreated.stream=trueretries: these return 201, send only the connection comment and end at once. The official service has no same-key retry semantics: identical official requests create distinct Sessions. Recovery staysstream=falseor the GET stream. The TS client raisesCreationStreamRetryErrorfor an empty creation stream instead of a 502./events: unchanged. It is live-only, never ends on its own, gains no new events and has no replay.agent.session.createdsnapshot: the committed post-admission Session, the same projection as the JSON 201 response (in_progressfor an input-bearing creation). Later events are still delivered exactly once.turn.completed,turn.failedandturn.cancelledcarry a top-levelusagecopied from the Turn snapshot, with explicitnullwhen unknown. It is never invented. The official service sendsnullat emission even when later reads are measured; Core sends the measured value it already has, which is documented.turn.created, its user item(s),session.in_progress, thenturn.in_progress, for creation,events.createand reservation promotion.Evidence
Campaign scan 2 events-tools findings EVT-01..04 and EVT-19: 4 owned official
noneSessions, 1,091 events validated against the pinned types, all deleted. Recorded incontracts/agents-api/history-events-usage.mdandoperation-evidence.mdrows 6 and 12.Validation
environment: none: Codex with Kimi K3 (including a function tool round trip) and MiniMax Code with MiniMax-M2.7.47fba93): all passed. The server closed the stream about 0.3 ms after idle, and the SDK loop ended on its own.createdwasin_progress, terminalusageequalled the Turn read (Codex measured, MiniMaxnull), and the start order was correct.-race), store (real PostgreSQL, including the silent-expiry scenario and both reviewer race variants) and contract tests. The pinned-SDK creation-stream, self-hosted and reference-retry scripts run inside the store tests.80f7a17was squashed onto main4f3822a(Ship a zero-node Core installer with opt-in local sandboxes #48, Align Environment Files create and list with official hosted responses #49). Every file exceptoperation-evidence.mdequals the reviewed state plus Align Environment Files create and list with official hosted responses #49's changes. In that document, this batch's evidence register entry was renamed from G to J, because Align Environment Files create and list with official hosted responses #49 also used G.make openapiis byte-identical.make -o check-web checkplus Web typecheck, core-doctor, the unit tests and the build all pass. The Playwright browser cases were not run on the server (no Google Chrome; skip approved by the user).make openapiis byte-identical.Deferred
No full protocol compatibility is claimed.
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.