Skip to content

refactor(agent-input): unify prompt usage accounting#198

Merged
cniska merged 14 commits intomainfrom
token-budget
Apr 14, 2026
Merged

refactor(agent-input): unify prompt usage accounting#198
cniska merged 14 commits intomainfrom
token-budget

Conversation

@cniska
Copy link
Copy Markdown
Owner

@cniska cniska commented Apr 14, 2026

Motivation

prompt usage accounting was split across agent input, lifecycle prepare, and lifecycle usage estimation, which made /usage less reliable and harder to reason about

Summary

  • centralize prompt budget accounting in createAgentInput with a dedicated prompt token budget helper
  • keep systemPromptTokens and toolTokens authoritative from requested usage values
  • remove prepare-phase usage mutation and rely on createAgentInput as the source of truth
  • use PromptUsage values directly when building lifecycle prompt breakdown totals
  • add regression tests for tool token reporting and over-budget system/tool reservation behavior

Fixes #195

@cniska cniska merged commit 2f1890c into main Apr 14, 2026
5 checks passed
@cniska cniska deleted the token-budget branch April 14, 2026 18:51
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.

refactor(agent-input): structured token budget tracking

1 participant