Repository navigation
Fix Pi turn settlement after native recovery - #5341
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8c0948e24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return; | ||
| } | ||
| const messages = run.end.messages ?? []; | ||
| const error = run.recoveryError ?? runSettlementError(event, messages); |
There was a problem hiding this comment.
Avoid duplicating exhausted-compaction errors
When automatic overflow recovery is exhausted (reason: "overflow" and willRetry: false after a length/error/aborted assistant), this promotes the compaction failure to the synthetic settlement error. That same compaction_end has already emitted a non-retry provider.error in delta-translation.ts:740-749, and the settlement-only agent_end then emits another from the same detail at delta-translation.ts:775-790; the assembler persists both, so one failed recovery appears twice to the user. Preserve the failed terminal boundary without emitting the second diagnostic for recoveryError.
Useful? React with 👍 / 👎.
… errors once When a run failed without a native retry and queued steering or follow-up work continued inside the same settlement, only the final run's outcome reached the thread, so the first failure was never shown. Forward that failure as a non-terminal provider error when the continuation starts, unless native overflow recovery handled it. An exhausted overflow recovery was reported twice: once from the compaction result and again from the settlement. Keep the failed boundary and drop the second diagnostic. Failed attempts no longer emit a token usage update when the provider reported no usage. Co-Authored-By: Claude Code <[email protected]>
The fake reported Pi 0.83.0 unless a test opted in, so the existing bridge suites exercised the legacy agent_end path that no supported Pi version takes. Default the fake to authoritative settlement and keep the legacy path for tests that ask for it. Co-Authored-By: Claude Code <[email protected]>
Human comments
What was wrong
The Pi provider finalized turns on
agent_endand ignoredagent_settled. Pi can still perform native overflow recovery or drain follow-up work after anagent_endwithoutwillRetry, so BB could complete the turn before that work finished. Structured assistantabortedoutcomes, and errors withouterrorMessage, could also be reported as successful. Both behaviors are present in BB 0.46.0 and upstream basee9ad6b0.What changed
No personal autonomy prompt, automatic
continue, additional retry loop, tool replay, live-provider reload, public SDK, CLI, or server/host protocol change. Native retry policy and explicit Stop/permission handling remain in place.How you verified
createAgentSession, its actual extension runner and lifecycle methods, isolated in-memory settings/session/credentials, andallowModelNetwork: false. It runs the BB extension with an adapted FD transport and verifies B starts inside A's asynchronous settlement handler before A's public settlement. It asserts per-run checkpoints/outcomes, B's processing state, independent boundaries, and cumulative usage. This is an in-process runtime regression, not a live model or full CLI subprocess test.pnpm exec turbo run prepare:bundled typecheck test lint --filter=bb-plugin-provider-pi --concurrency=2: 11 successful tasks; 285 tests passed, one existing Bun-only test skipped. Provider bundle preparation passed.pnpm exec oxfmt --checkandgit diff --check: passed.Settlement ownership relies on Pi's CLI-first extension loading, verified in the pinned 0.84.0 runtime. A reversed-handler test fails closed when another extension has already started an active run; arbitrary nested SDK/wrapper registration order is not claimed. The supported 1.x capability classification and bridge behavior are covered by fixtures, not a second real-runtime run.