Skip to content

fix(server): preserve context occupancy across model handoffs - #13871

Merged
Yash-Singh1 merged 1 commit into
t3code/codex-turn-mappingfrom
t3code/fix-handoff-context-allowance
Sep 26, 2026
Merged

Yash-Singh1 merged 1 commit into
t3code/codex-turn-mappingfrom
t3code/fix-handoff-context-allowance

Conversation

@Yash-Singh1

Copy link
Copy Markdown
Collaborator

Summary

  • Switching models on the same native thread no longer drops the measured context size and replaces it with a byte-length estimate.
  • The handoff keeps that occupancy, drops the previous model's compaction threshold, and uses the new model's window when it is known. A conversation that still fits is no longer refused with "Insufficient context allowance."
  • A genuinely full window still blocks the handoff. A new native thread still starts with an empty occupancy.

Test plan

  • vp test run src/orchestration-v2/ContextHandoffBudget.test.ts
  • vp test run src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
  • Switch models on a thread that previously hit a usage limit and confirm the next turn starts instead of reporting insufficient context allowance
  • Branching the last turn of that thread still runs
  • Switching onto a model whose window is actually smaller than the current occupancy still refuses the handoff

Made with Cursor

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 4.9 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅
Codex Live turn messages — 2 — 8 ✅
Claude Total thread wire — 4.9 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅
Claude Live turn messages — 2 — 8 ✅

Baseline: unavailable · PR result: b892868 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 106.1 KiB
  • Claude decoded thread snapshot: 106.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@macroscopeapp

macroscopeapp Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b892868

Macroscope's review found this PR approvable — This is a focused server bug fix that preserves measured context occupancy across existing model handoffs while resetting only stale capacity metadata, with new-thread behavior unchanged. The production change is localized and supported by unit and integration coverage for model switches, retries, telemetry, and native replacement.

You can add or adjust custom eligibility rules. Learn more.

@Yash-Singh1
Yash-Singh1 merged commit 6cae455 into t3code/codex-turn-mapping Sep 26, 2026
24 checks passed
@Yash-Singh1
Yash-Singh1 deleted the t3code/fix-handoff-context-allowance branch September 26, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant