Skip to content

feat(phase-12): add token cost controls - #6

Merged
lyxnbclass merged 3 commits into
masterfrom
codex/phase-12-cost-control
Aug 20, 2026
Merged

lyxnbclass merged 3 commits into
masterfrom
codex/phase-12-cost-control

Conversation

@lyxnbclass

Copy link
Copy Markdown
Owner

What changed

  • add provider-independent session token budgets and per-request output limits
  • estimate message and tool-schema input cost before every model step
  • stop with budget_exhausted before contacting the provider when the request cannot fit
  • preserve reported token usage across resumed sessions and expose /budget
  • document configuration, threat model, validation, and known limits

Why

Long-running tool loops can continue spending model tokens even when the user intended a bounded task. This stage adds an explicit opt-in guard without hard-coding volatile provider prices or claiming exact billing.

User impact

Users can set --token-budget / MINICODE_SESSION_TOKEN_BUDGET and --max-output-tokens / MINICODE_MAX_OUTPUT_TOKENS. Existing behavior is unchanged when neither limit is configured.

Validation

  • 107 passed stage-related regression
  • 298 passed, 3 skipped full regression
  • branch coverage 85.58%
  • Ruff and Mypy passed
  • compileall, sdist/wheel build, and offline MockModel demo passed

@lyxnbclass
lyxnbclass marked this pull request as ready for review August 20, 2026 02:34
@lyxnbclass
lyxnbclass merged commit 74460e6 into master Aug 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant