# Measure Claude Code agent_summary spend on background-agent status labels

> Upgrade past the cache-miss fix, turn on OpenTelemetry, group api_request events by query_source, then shrink or re-route Agent-tool subagents so status-label calls stop eating your quota.

- **Category:** [Coding](https://stepgleam.com/categories/coding)
- **Difficulty:** Intermediate
- **Time:** ~35 minutes
- **Tools:** Claude Code, OpenTelemetry (Claude Code monitoring), Claude Code costs docs
- **Reliability score:** 86/100
- **Steps:** 6
- **Last updated:** 2026-10-30
- **Published:** 2026-10-30

## Tools used

- [Claude Code](https://code.claude.com/docs/en/overview) — Runs background / Agent-tool subagents that trigger agent_summary
- [OpenTelemetry (Claude Code monitoring)](https://code.claude.com/docs/en/monitoring-usage) — Exports claude_code.api_request events so you can group by query_source
- [Claude Code costs docs](https://code.claude.com/docs/en/costs) — Official cost and background-usage notes to contrast with agent labels

## What you'll get

A measured agent_summary share from your own OTel export, Claude Code ≥ 2.1.311, and a smaller bill of active Agent-tool subagents (or work moved into workflows that do not get summarized).

## Who this is for

Developers who run Claude Code background / Agent-tool subagents and see usage limits or unexplained spend.

## Before you start

On 29–30 October 2026, Flamerix AI's gist about Claude Code's agent_summary timer hit Hacker News. A Claude Code engineer (edwinarbus) confirmed the mechanism: only actively working background agents get a ~30-second summary call used for the agents-panel status label. Fleet average is about 2–6% of cost; heavy Agent-tool users measured 8–18% (and higher). Josh Builds walked through how he would check his own Mac. This guide sticks to those human sources plus the official monitoring docs. There is still no supported off switch; unofficial Bun preloads and FORK_SUBAGENT=0 trade-offs are noted as gaps, not recommended steps.

## Steps

### Step 1: Upgrade Claude Code to 2.1.311 or newer

**Tool:** Claude Code

edwinarbus (Claude Code engineer on HN): a fix for the most expensive case — summaries that miss the prompt cache — shipped in **2.1.311+**, and a cheaper short-notes mode is in progress. Josh Builds: *"Update first. Run `claude --version` and move to 2.1.311 or later."* His Mac was already on 2.1.312 when he wrote the piece.

**Why this works:** Cache-miss summaries were the costliest slice; staying below 2.1.311 leaves that hole open.

**Prompt:**

```
claude --version
```

[Open step 1](https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels#step-1)

### Step 2: Turn on OpenTelemetry logs for a day of real work

**Tool:** OpenTelemetry (Claude Code monitoring)

Josh Builds: set `CLAUDE_CODE_ENABLE_TELEMETRY` to 1 and send the logs exporter to your collector, or to the console for a quick look. Official docs use the same gate and show `OTEL_LOGS_EXPORTER=console` (or `otlp`) before running `claude`. rflcrz's August measurement instead captured raw bodies with `OTEL_LOG_RAW_API_BODIES` over a 4-hour, 27-subagent session — use whichever exporter you already trust; the point is to see requests that never appear in on-disk transcripts.

**Why this works:** Transcript-based cost tools miss agent_summary because those calls use skipTranscript.

**Prompt:**

```
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=console
claude
```

[Open step 2](https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels#step-2)

### Step 3: Group claude_code.api_request events by query_source and find agent_summary

**Tool:** OpenTelemetry (Claude Code monitoring)

Josh Builds: *"Group requests by query_source. Each API request event names the part of Claude Code that made it. Compare agent_summary with your main thread and subagents."* edwinarbus uses the same `agent_summary` name in Anthropic's telemetry. rflcrz and sylvain-artois both published personal tables that isolate that source. Official docs document `query_source` on `claude_code.api_request` events. Sum `cost_usd` (or tokens) for `agent_summary` vs the rest of your session.

**Why this works:** Without the split you will keep blaming prompts for spend that never entered the chat.

[Open step 3](https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels#step-3)

### Step 4: Prefer workflows over free-form Agent-tool subagents when the work fits

**Tool:** Claude Code

jakozaur on HN: impact is *"just for subagents; workflows do not seem affected,"* and many users on Ultracode-style workflows see less pain (~8% in his sessions). chrisvaillancourt on #86879 after reading the 2.1.312 bundle: *"Workflow agents aren\'t summarized. Only Agent-tool subagents get the timer… Moving big scripted fan-outs into workflows avoids the cost and keeps forks."*

**Why this works:** Same useful work without arming the 30-second status timer.

[Open step 4](https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels#step-4)

### Step 5: Shrink active Agent-tool fan-out and transcript size

**Tool:** Claude Code

edwinarbus: summaries apply only to **actively working** background agents; idle ones do not. Josh Builds: *"Shrink what each agent holds. The cost tracks context size, so smaller, shorter-lived background agents are cheaper to label."* sylvain-artois measured a ~380k-context generator agent paying roughly 45M cache-read tokens an hour through summary ticks alone. simon83's heavy research-subagent week landed near 16%; jakozaur's shorter-context sessions nearer 8%.

**Why this works:** Label cost scales with concurrent active agents and how fat each transcript is.

[Open step 5](https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels#step-5)

### Step 6: Put routine background agents on a cheaper model; leave the official off-switch as a gap

**Tool:** Claude Code

Josh Builds: *"Pick agent models on purpose. The label runs on the agent's own model, so an Opus agent gets Opus labels. Routine background work can go to a smaller model."* He also refuses the community Bun preload for teams. edwinarbus says a cheaper short-notes mode is coming; #86879 (open since August) still asks for a supported disable. **Gap:** there is no documented setting that turns only agent_summary off while keeping Agent-tool subagents. `CLAUDE_CODE_FORK_SUBAGENT=0` stops summaries for some users by disabling fork subagents entirely — a blunt trade-off, not a surgical switch. Do not invent an off flag that does not exist.

**Why this works:** Cheaper agent model halves label spend without waiting on Anthropic; a real toggle is still missing.

[Open step 6](https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels#step-6)

## Pro tips

- Idle background agents do not get summaries; cost tracks active agents and transcript size.
- Workflow agents are not summarized on 2.1.312; only Agent-tool subagents arm the timer.

## Common mistakes

- Assuming the configurable status-line docs mean agent labels are free; that page is about your local statusline script.
- Installing a community Bun preload without reading it; Josh Builds would not put that on a team machine, and updates can silently undo it.

## FAQ

### Is Anthropic's 2% wrong if I measured 16%?

Both can be true. edwinarbus said 16.4% sounds like a team running mostly background agents; fleet average across telemetry users was about 2% API / about 6% in the terminal.

### Will CLAUDE_CODE_AGENT_PROGRESS_SUMMARIES=0 turn it off?

chrisvaillancourt checked the 2.1.312 bundle: that env can only enable summaries, not disable them.

---

Canonical guide: https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels
Read this guide as Markdown: https://stepgleam.com/guides/measure-claude-code-agent-summary-spend-on-status-labels.md
