Skip to content

feat: token-efficiency reinforcement — wiki page + token-report.sh + skill directives (run tokeff) - #132

Merged
choiyounggi merged 5 commits into
mainfrom
integ/tokeff
Aug 21, 2026
Merged

feat: token-efficiency reinforcement — wiki page + token-report.sh + skill directives (run tokeff)#132
choiyounggi merged 5 commits into
mainfrom
integ/tokeff

Conversation

@choiyounggi

Copy link
Copy Markdown
Owner

Summary

Token-efficiency reinforcement for orchestration runs — grounded in a measured audit (2026-08-21) of live dev-loop coordinator/worker transcripts and verified Anthropic sources. Three pieces, one per task of orchestration run tokeff:

  • wiki (t1): new page wiki/infrastructure/agent-orchestration/session-context-token-budget.md — 5 sourced directive clusters: cache mechanics (reads ~0.1x, writes ~1.25x; accumulated context is the cost driver), phase-boundary /compact//clear, visual verification delegated to subagents (current 28px-patch image formula, not the outdated /750 one), bounded tool output, architecture-scaled slot budgets (4x/15x/7x measurements). Routed in both index layers.
  • script (t3): skills/orchestrate/scripts/token-report.sh — per-session + total report (calls, output tokens, cache hit %, final/peak context) from session transcript JSONL; --cwd project-path mapping; LO_CTX_WARN peak-context warnings (default 300000); fail-fast exit 0/2/4. 14 bats cases on synthetic fixtures.
  • skill docs (t2): SKILL.md gains a "Coordinator token budget" section (no image Reads into the coordinator — delegate to a subagent; bounded pane/status reads; suggest /compact at the two human gates) and a teardown token-audit step invoking token-report.sh; session-prompt worker protocol gains token-hygiene item [4]; brief template gains a token-hygiene constraint. 6 new doc-gates with negative controls; send-prompt cksum guard bumped per its own protocol in the same commit.

Ingest report (wiki addition)

  • Route: infrastructure / agent-orchestration (existing category; no page owned token budgeting — merge target absent, new page justified)
  • Sourcing: every claim carries a URL fetched and quote-verified on 2026-08-21 (platform.claude.com prompt-caching & vision, code.claude.com costs / best-practices / sub-agents, anthropic.com engineering: effective-context-engineering, multi-agent-research-system) + one field-evidence block from the local audit
  • Corrections applied during verification: image token cost cited with the current ⌈w/28⌉ × ⌈h/28⌉ patch formula (the circulating (w×h)/750 figure is outdated); "superlinear" not attributed to Anthropic — the verified resend mechanism is stated in the page's own voice
  • Triggers: category-index "load when" row + root INDEX.md infrastructure clause extended with session context/token budgeting

Verification

  • Full bats suite on the integration branch: 651 ok / 0 not ok (pre-existing BW01 warnings unchanged)
  • Per-task: independent coordinator re-runs — wiki suites 21/21 (t1), token-report 14/14 + hand-derived fixture math (t3), doc-gates + send-prompt 71/71 (t2)
  • Four-lens review per task (plan conformance / wiki re-route / execution-environment reality / write ordering): no findings
  • Dogfood: this run's own teardown audit ran the new script — worker peaks 158k/229k/205k ctx, cache hit 95.2–97.9%, zero warn: lines

🤖 Generated with Claude Code

https://claude.ai/code/session_01DSmPhBqtbkfieq2kTzLWhJ

choiyounggi and others added 5 commits August 21, 2026 23:41
…ration)

Add a sourced wiki page on token-efficient context management for
long-lived coordinator/worker agent sessions: cache pricing mechanics,
/compact vs /clear at phase boundaries, delegating visual verification
to subagents (with the current image patch-token formula), bounding
tool output, and sizing orchestrated runs against measured Anthropic
multipliers. Routes into wiki/infrastructure/index.md and INDEX.md.

t1 of 3 (t1-wiki-token-efficiency): t2 will cite this page's slug from
the orchestrate skill docs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WjskPUNcUjsE9qzcxhuLGv
Ships token-report.sh: reports per-session and total token usage (calls,
output tokens, cache hit %, final/peak context) from Claude Code session
transcript JSONL, so an orchestration run can audit its own token
efficiency at teardown. POSIX sh + jq, fail-fast validation (exit 2 usage,
exit 4 malformed LO_CTX_WARN), with a synthetic-fixture bats suite.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PucyFRX7yfYniePZa9oVaA
…mplates

Wire t1's token-budget wiki page and t3's token-report.sh into the
orchestrate skill's own instructions: a coordinator token-budget section
plus a post-teardown token-report audit step in SKILL.md, a bounded-output
and visual-delegation rule in session-prompt.md's subagent protocol, and a
token-hygiene constraint line in brief.md. Each cites
wiki/infrastructure/agent-orchestration/session-context-token-budget.md.

Sharpens the byte-cksum guard in tests/send-prompt.bats that reddened from
the session-prompt.md addition, and adds tests/orchestrate-token-budget.bats
with dedicated doc-gates (positive assertion + negative control) for the
SKILL.md and brief.md changes.
… union of index rows

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DSmPhBqtbkfieq2kTzLWhJ
@choiyounggi
choiyounggi merged commit c9066e6 into main Aug 21, 2026
2 checks passed
@choiyounggi
choiyounggi deleted the integ/tokeff branch August 21, 2026 15:57
choiyounggi added a commit that referenced this pull request Aug 21, 2026
… page + token-report.sh + skill directives) (#132) (#133)

Claude-Session: https://claude.ai/code/session_01DSmPhBqtbkfieq2kTzLWhJ

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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