1---2name: token-budget-optimizer3description: compact context, reuse existing runtime artifacts, and choose the smallest authoritative surface before expanding prompt history. use when the task is growing large, when earlier repo intelligence already exists, or when repeated rescans would waste tokens without adding new evidence.4---56# Token Budget Optimizer78## Trigger Signals910- the prompt is getting long and earlier repo context is being repeated11- the repo already has `AGENTS.md`, `.hforge/runtime/`, specs, plans, or review artifacts that can answer the next question12- the task is investigative or iterative enough that careless re-reading will waste tokens13- the agent is about to scan broad directory trees before checking existing runtime summaries1415## Inspect First1617- `.hforge/agent-manifest.json` and `.hforge/generated/agent-command-catalog.json`18- `.hforge/runtime/index.json`, `.hforge/runtime/repo/repo-map.json`, and `.hforge/runtime/repo/recommendations.json`19- active guidance bridges such as `AGENTS.md`, `CLAUDE.md`, and `.agents/skills/<skill>/SKILL.md`20- any existing `spec.md`, `plan.md`, `tasks.md`, review output, or decision record relevant to the current task21- `skills/token-budget-optimizer/scripts/inspect_token_surfaces.py` when a deterministic token-surface audit would help2223## Workflow24251. identify the concrete question the agent must answer next and avoid reading more than that question requires262. rank existing surfaces by authority, freshness, and cost, preferring hidden runtime summaries and durable artifacts before broad source scans273. reuse prior findings, repo maps, decision records, and task artifacts instead of re-deriving them from scratch284. compact the active context into a short working set: current goal, authoritative surfaces, open questions, and the next small evidence step295. escalate to deeper reads only when the compacted working set cannot answer the task safely3031## Output Contract3233- a short context budget summary with the current goal and the smallest authoritative surfaces to keep loaded34- a reuse plan listing which runtime artifacts, docs, or task artifacts should be trusted instead of reread35- compaction candidates describing what can be summarized once and then dropped from active context36- unresolved gaps that still require new evidence or deeper file reads3738## Failure Modes3940- runtime artifacts are stale, missing, or do not cover the active question41- the task is genuinely novel and prior summaries are no longer trustworthy42- the agent mistakes low-cost summaries for high-authority truth and skips required verification4344## Escalation4546- escalate when the repo has conflicting guidance across `AGENTS.md`, runtime summaries, and product code47- escalate when token saving would hide a risky detail such as a release gate, migration step, or support constraint48- escalate when there is no reliable compact surface and the agent must build a new authoritative summary first4950## References5152- `skills/token-budget-optimizer/references/audit-dimensions.md`53- `skills/token-budget-optimizer/references/promotion-ladder.md`54- `skills/token-budget-optimizer/references/scoring-model.md`55- `skills/token-budget-optimizer/references/report-template.md`56- `skills/token-budget-optimizer/scripts/inspect_token_surfaces.py`