Dynamic Review: calibrate the byte-to-token estimate of the token cap
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start with the token reservation in BudgetLedger.reserve_call, which PR #234 introduced, and read the byte-based upper bound it uses. The first step is measuring request bytes against prompt_tokens per call in the #202 trial run, which needs a live provider, so this is not a first-timer task. Done means a written decision on the estimate, the calibration data visible in the trial logs, and tests T01 and T02 passing without a real model call.
Written by the indexing model from the issue text.
Description
Part of epic #193. Not a blocker for enabling opencode in #202.
Problem
The token reservation in BudgetLedger.reserve_call (#231, PR #234) uses UTF-8 bytes as a proven upper bound on tokens. For code, a real token is about 3-4 bytes, so the reserved input is roughly 3-4x the real prompt. Each call re-sends the whole history, so runs end with dynamic_budget_exceeded at roughly 40-60 % of the real consumption. This fails closed, but it makes max_total_tokens look much bigger than what a review can actually use.
Example: settled 60k, next prompt 90 KB (about 25k real tokens), allowance 4k reserves about 94k and is refused (60 + 94 > 120), although the real usage would be about 89k.
Source: review of #234, https://github.com/ExpidetGames/code-reviewer/pull/234#pullrequestreview-5510660836 (finding 1).
Task
- In the first #202 trial run, measure request bytes against the provider's
prompt_tokensper call. - Decide: a calibrated estimate (for example
bytes x observed tokens-per-bytewith a margin, labelled non-proven, the byte bound staying as the hard window check), a highermax_total_tokens, or a verified tokenizer. - Keep the byte bound as the sound fallback unless the replacement is justified in writing.
Test cases
- T01: the calibration input (bytes and
prompt_tokensper call) is visible in a trial run's logs or result. - T02: whatever estimate is chosen never lets
settled + in_flight + reservationexceed the cap by more than the documented margin; a test per level, no real model call.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 1
- Avg merge
- 1h 18m
- Merged PRs (30d)
- 186
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the 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 ExpidetGames/code-reviewer
-
area: app type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ExpidetGames/code-reviewer#308 ·
Maintainers usually reply within 1 day
-
type: docs
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ExpidetGames/code-reviewer#94 ·
Maintainers usually reply within 1 day
-
area: app post-mvp type: feature
Difficulty 5/5 Over a week Newbie friendliness 12/100
ExpidetGames/code-reviewer#339 ·
Maintainers usually reply within 1 day
-
area: runner post-mvp type: feature
Difficulty 5/5 Over a week Newbie friendliness 18/100
ExpidetGames/code-reviewer#338 ·
Maintainers usually reply within 1 day
-
area: runner post-mvp type: feature
Difficulty 5/5 Over a week Newbie friendliness 12/100
ExpidetGames/code-reviewer#337 ·
Maintainers usually reply within 1 day
All issues in ExpidetGames/code-reviewer
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
melgarafael/DeskcommCRM#3000 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
callstackincubator/simlock#639 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
aws/agentcore-cli#2606 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 7 days
-
ai-driven-qa bug Cosmetic
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day