🤖 perf: a stage opened at settlement but not due at the next turn start can stop the turn again
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
Research direction
Read src/node/services/contextManagement/strategies/tokenBudget.ts and trace dueTurnStartStage and prepareTurnStartStage, then follow how settlement uses nextRequestTokens from streamManager.ts and contextBudgetCounting.ts. Add a test for a settlement that opens a stage when the next turn start’s full count is below its point; done means that turn does not stop again with another “Continue”.
Written by the indexing model from the issue text.
Description
Found from code reading during the final check of #7332, not reproduced. Related: #5223, #5286, #7331.
Problem
In Token Budget mode, a settled tool step can open a handoff or final stage that the next turn start does not see as due. Settlement then stops the turn and queues a "Continue". That turn start publishes no warning and sets no declined marker, so the next settlement can stop the turn again with another "Continue".
Why it can happen
- Settlement decides on the anchored next-request estimate: the provider's input count plus an estimate of the appended messages only (
estimateAnchoredRequestTokensForModel,src/node/services/contextBudgetCounting.ts, passed asnextRequestTokensfromstreamManager.ts). - The turn start decides on the full count of the built request (
dueTurnStartStageandprepareTurnStartStageinsrc/node/services/contextManagement/strategies/tokenBudget.ts). prepareTurnStartStagesetsstageDeclinedStreamonly when a stage is due. If the full count is below the stage point, nothing marks the stream, sosettlesWithoutStagedoes not stop the next settlement from opening the stage again.
Trigger
The full count must run below provider usage (k < 1, where k = estimate / provider usage). Measured k today is above 1 (OpenAI about 1.3 to 1.6, Claude about 1.04 to 1.36, see #5223), so this is expected to be rare.
Scope
Main already has this path: before #7332, settlement opened stages on provider usage, which can also sit above the turn start's full count. #7332 opens stages on the anchored estimate and widens the path only by the difference between the anchored and the full counts. No fix is in #7332.
Acceptance
- Test: a settlement opens a stage, the next turn start's full count is below the stage point, and the turn does not stop again with another "Continue".
Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $525.35
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 140
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 946
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from coder/xum
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
🤖 fix: a Daytona connection test started before a settings save can show the old key as connectedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
Similar issues
-
[Bug]: Device screenshot fails with 500 on iPhone Duo (Xcode 27.2): serve-sim calls simctl without --displayPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
pingdotgg/t3code#24900 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
inu-appcenter/UNIDorm-web#411 ·
Maintainers usually reply within 1 day
-
🐛 bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ranxianglei/billion-context#4720 ·
Maintainers usually reply within 1 day
-
area:arcade game p3-medium ready-for-agent type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
fderuiter/deruiter.dev#2840 ·
Maintainers usually reply within 1 day