{"success":true,"name":"agent-token-economy","description":"Use when auditing agent tokens, engines or architecture.","category":"brimind","path":"brimind/agent-token-economy/SKILL.md","file":"SKILL.md","content":"---\nname: agent-token-economy\ndescription: Use when auditing agent tokens, engines or architecture.\nversion: 1.0.0\nauthor: Hermes Agent\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [tokens, context, agents, audit]\n    related_skills: [codebase-inspection]\n---\n\n# Agent token economy: explain and audit\n\n## When to Use\n\nClass: questions like \"why are you economical with tokens\", \"does Hermes do X\", \"check if our agents use that method\". Covers both the Hermes runtime (this agent) and the BRIMIND agent fleet in [PATH]\n\n## Procedure\n\n1. Pin the subject first. \"You\" can mean the model's instructions, the Hermes runtime, or the repo's agents. If the user corrects the subject (e.g. \"I mean Hermes\"), answer about the runtime's mechanisms, not the prompt rules.\n2. For Hermes: answer from the visible tool schemas/system prompt (deferred tools via tool_search, skills index + skill_view, output truncation with full text saved to disk, execute_code filtering, subagent summaries, memory char budget, batched calls). State plainly what was NOT verified (context compression policy, prompt caching) instead of guessing.\n3. Frame purpose correctly: Hermes is a general-purpose agent; token economy is a design constraint (long multi-tool runs would otherwise blow the context), not its purpose.\n4. For the repo's agents: map each mechanism to real code with path:line evidence. Use rg with -m and cut -c1-200, batched in few calls; start from references/brimind-fleet-map.md instead of rediscovering the launcher.\n5. Report as a per-mechanism verdict (Yes / Partly / Rule only / No) + evidence path, then list gaps and what was not checked (e.g. Claude/Codex CLIs' own limits, no live token measurement).\n\n## Fixing and rolling out (fleet changes)\n\n1. Commit + push a snapshot of the repo BEFORE changing anything when the user asks for fixes (scan staged diff for secrets first; exclude junk paths).\n2. Savings % per fix: compute from codex-box jsonl (sum last_token_usage input/cached, dedupe repeated total_token_usage events, split first-turn uncached). Report both \"all input\" and \"uncached\" columns, label them ESTIMATES, and offer a re-measure date — never present projected savings as measured.\n3. Engine on/off and order live in agents/registry.json (`engines`, `engineOrder`) and are read every turn — no worker restart needed. Back up the registry before bulk edits, then print every agent's resolved chain (engines.cjs chainOf) as proof.\n4. Before comparing engines (Hermes/X vs X same model), probe each rail with a one-line \"Reply OK\" run: a quota-exhausted provider fails both the direct CLI and the Hermes route, and the comparison is void for that side.\n5. When the owner turns on a fleet-wide experiment, tell the R&D agent (Rayen, `rnd`) by letter (`node agents/mail.mjs send --from hermes --to rnd ... --needs-reply --answer-by +24h`) so someone watches tokens and quality; letters are batched (5 or 2 h) unless --urgent.\n6. Brain check (does an agent's context suffice): 5 in-character questions per agent on one resumed Hermes session (`-t todo` = no side effects, cwd = scratch), charter as first message, then an Opus judge scoring 1-5 + verdict; cache one JSON per agent so reruns skip finished agents. Run ~4 agents in parallel in the background — 20 agents exceed one foreground timeout.\n\n## Explaining agent architecture\n\nUser asks \"how could agents be organised / subagents\": answer with ASCII drawings using the REAL agent names from agents/registry.json (fetch name + title first), mark what the fleet uses today, give one-line +/- per option and a pick. Patterns and the current BRIMIND mapping are in references/agent-architectures.md (read it first). Be honest about subagents: background processes and test-spawned `hermes -z` sessions are not delegation. Before stating what an engine \"has\" (subagents, CLAUDE.md, skills), check the body-vs-brain table in that reference or the code (rg the worker for tool restrictions); if an earlier answer was wrong, correct it in the next reply in one line. Redraw on the SAME diagram when the user asks to add a layer (tag parts [H]/[C] rather than starting a new picture).\n\n## User preferences (this owner)\n\n- Very short replies: a few lines + one plain table. Lead with the answer; no process narration.\n- He interrupts often with new orders; the latest message wins — drop or background the old step and answer the new one at once.\n- \"npm run dev\" for the dashboard means the dev server on :3999 via a systemd drop-in, not a prod build (see fleet map).\n\n## Presentation (CLI)\n\n- The plain CLI renders neither Markdown nor ANSI colors in replies, and terminal tool output strips colors. When the user asks for a colored table: write a small bash script with ANSI codes to the scratch dir, run it once to verify layout, show the plain-text table in the reply, and give the command to run it for colors.\n- Keep the explanation short; one table beats prose for mechanism comparisons.\n\n## References\n\n- references/brimind-fleet-map.md — where each token-saving mechanism lives in the unitary repo, engine chain + dashboard + mail wiring, known gaps.\n- references/agent-architectures.md — 10 multi-agent patterns, BRIMIND's current mix, token trade-offs of subagents.\n","linked_files":["references/agent-architectures.md","references/brimind-fleet-map.md"],"origin":"brimind","owner_id":null,"source":"router"}