fix(agent-gateway): seed agent phase when a transcript attaches mid-turn - #365
Merged
Merged
Conversation
A transcript bound to a turn already blocked on an approval got the pending interaction but no meta.agent, and no later event repaired it.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 32 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Merged
elkaix
pushed a commit
that referenced
this pull request
Oct 3, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @pymodel/pythinker-code@2.5.2 ### Patch Changes - [#364](#364) [`c431d50`](c431d50) Thanks [@elkaix](https://github.com/elkaix)! - A session whose model was deleted or lost its provider switches to the best available model at the next turn, with a warning, instead of failing the turn. - [#365](#365) [`81f1070`](81f1070) Thanks [@elkaix](https://github.com/elkaix)! - Clients that open a session while a tool approval is pending now show the agent's status instead of none. ## @pymodel/pythinker-desktop@1.6.2 ### Patch Changes - [#364](#364) [`c431d50`](c431d50) Thanks [@elkaix](https://github.com/elkaix)! - A session whose model was deleted or lost its provider switches to the best available model at the next turn, with a warning, instead of failing the turn. - [#365](#365) [`81f1070`](81f1070) Thanks [@elkaix](https://github.com/elkaix)! - Clients that open a session while a tool approval is pending now show the agent's status instead of none. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Requirement or Bug
Resolve #350
Bug Reproduction Steps
In
transcriptContract.e2e.test.tsS3, addawait new Promise((r) => setTimeout(r, 3000));aftersubmitPrompt. It then fails every time withexpect(mid.meta.agent).toBeDefined(). Without the sleep it fails about 1 run in 4, and more often under load.Root Cause
The transcript store binds to the event bus lazily, on the first transcript request.
meta.agent.phasecomes only from the projector's phase merge, and that merge runs only when a new bus event arrives. On a late attach,subscribeAgent(coreBinding.ts) restores the running turn withseedActiveTurn, but it does not restore the phase.seedPendingInteractionsthen adds the approval. The turn is blocked on that approval, so no further event comes andmeta.agentstays undefined. In the product, a client that opens or reloads a session while an approval is pending shows the approval with no agent status. Fundamental fix.Code Changes
coreEventMap.ts: newAgentTranscriptProjector.seedPhase(). It recomputes the phase from the activity snapshot and the pending approvals, and returns onemeta.merge. The tracker set-up moves totracker(), whichphaseForreuses.coreBinding.ts: when attaching to a turn that is already running, applyseedPhase()afterseedActiveTurn. Idle and new agents are not touched. A later phase event with the same value is deduplicated by the tracker'slastPhaseKey.transcript.test.tschecks thatseedPhase()givesawaiting_approvalfor a turn blocked on an approval.Not in scope:
meta.agent.modelandmeta.agent.permissionon late attach. S3 needs only the phase.Behavior Changes and Affected Users
meta.agentmissing until the next phase event (never, if the turn is blocked on an approval)meta.agent.phaseis set immediatelymeta.agent.phasefrom live eventsConsumers: web, desktop, and inspector clients that read
meta.agent.phase. The wire shape is unchanged. Verification: forced-late S3 fails 2/2 without the fix and passes 2/2 with it. Full agent-gateway suite: 1408/1408.No quarantine for S3 exists in the repo, so there is nothing to remove.
Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.