[Bug] /context command doesn't display tokens from .claude/agents/ files

Resolved 💬 5 comments Opened Jan 9, 2026 by ashmuk Closed Feb 24, 2026

Bug Description
Subject: /context doesn't show tokens consumed by .claude/agents/ files

Issue:
When a project uses .claude/agents/*.md to define subagent policies (analyst, architect, builder, reviewer), these files are loaded into conversation context but are not displayed in /context output. The tokens (~2.5k in my case for 4 agent files) get buried in the "Messages" category, making it impossible for users to:

  1. See what's consuming context - No visibility that agent policies are loaded
  2. Optimize token usage - Can't tell if all agents should be loaded or just relevant ones
  3. Debug high token counts - "Messages" count appears inflated without explanation

Current /context output:
Memory files
└ ~/.claude/CLAUDE.md: 86 tokens
└ CLAUDE.md: 1.2k tokens

Skills
└ define, design, implement, review: 119 tokens

Messages: 15.1k tokens ← includes hidden ~2.5k from agents

Expected behavior:
Either:

  • Option A: Add a new section showing loaded agent policies:

Agents · /.claude/agents
└ analyst.md: 630 tokens
└ architect.md: 585 tokens
└ builder.md: 670 tokens
└ reviewer.md: 680 tokens

  • Option B: Lazy-load agents only when relevant skills are invoked (e.g., /define loads analyst.md only)

Impact: Medium - affects advanced users with multi-agent setups who need token transparency

Environment Info

  • Platform: darwin
  • Terminal: tmux
  • Version: 2.1.2
  • Feedback ID: 9c24c916-b21c-45b9-b215-acfcbd319457

Errors

[{"error":"Error: Request was aborted.\n    at _QA._createMessage (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:496:3157)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2026-01-09T05:16:06.472Z"},{"error":"Error: 1P event logging: 39 events failed to export\n    at ji1.queueFailedEvents (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:262:2038)\n    at async ji1.doExport (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:262:1195)","timestamp":"2026-01-09T05:46:35.953Z"},{"error":"Error: {\"stack\":\"Error: Failed to export 39 events\\n    at ji1.doExport (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:262:1297)\",\"message\":\"Failed to export 39 events\",\"name\":\"Error\"}\n    at nW0.error (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1823:34862)\n    at ic1.error (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:256:10502)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:256:41527\n    at Jb3 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:256:42073)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:257:20245","timestamp":"2026-01-09T05:46:35.954Z"},{"error":"Error: 1P event logging: 5 events failed to export\n    at ji1.queueFailedEvents (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:262:2038)\n    at async ji1.doExport (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:262:1195)","timestamp":"2026-01-09T05:46:43.919Z"},{"error":"Error: {\"stack\":\"Error: Failed to export 5 events\\n    at ji1.doExport (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:262:1297)\",\"message\":\"Failed to export 5 events\",\"name\":\"Error\"}\n    at nW0.error (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1823:34862)\n    at ic1.error (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:256:10502)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:256:41527\n    at Jb3 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:256:42073)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:257:20245","timestamp":"2026-01-09T05:46:43.919Z"}]

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗