-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add max_context_tokens to agent YAML for enforced context budget #699
Copy link
Copy link
Open
Labels
Description
Problem
Agent YAML has no context limit field. website ($11.49/run, 15M cache tokens) and intelligence ($10.92/run, 13M cache tokens) account for 36% of org cycle spend due to unconstrained context bloat.
budget.per_run documents a soft cost cap but does not enforce context limits. Agents silently accumulate 13-15M tokens without warning or abort.
Proposed Solution
Add optional context section to agent YAML frontmatter:
context:
max_tokens: 3000000
warn_at: 2000000If context would exceed max_tokens at invocation, log error and abort. If warn_at exceeded, emit structured warning with current token count.
Alternatives Applied
- context_from narrowing (ops applied 2026-03-31, hq commit dabfadbd) — reduces loaded memory but does not prevent runtime accumulation
- CLAUDE.md context diet instructions — behavioral, not enforced
Reference
analytics/reports/execution-economics-2026-03-28.md | hq #393 | source: operations-lead 2026-03-31
Reactions are currently unavailable