Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Dynamic Review: calibrate the byte-to-token estimate of the token cap

Open
#235 0 comments 0 reactions 0 assignees View on GitHub

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
Domain
ai, backend

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

area: runner type: chore

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_tokens per call.
  • Decide: a calibrated estimate (for example bytes x observed tokens-per-byte with a margin, labelled non-proven, the byte bound staying as the hard window check), a higher max_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_tokens per call) is visible in a trial run's logs or result.
  • T02: whatever estimate is chosen never lets settled + in_flight + reservation exceed 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ExpidetGames/code-reviewer

All issues in ExpidetGames/code-reviewer

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.