# Optimizing Claude Code Token Usage by Disabling Agent Summaries

A technical workaround to prevent unnecessary background agent transcript transmissions and token consumption.

- **Source:** [Hacker News (news.ycombinator.com)](https://brifing.si/source/13c923cd-6d99-442b-9b8b-1181f4d8cd91)
- **Published:** 2026-10-29
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://gist.github.com/flamerix-ai/c3905705cc4205e5de3011fa2e74efce>
- **On Brifing:** https://brifing.si/s/9830ef18-bcb5-4941-a26a-c297dacb343e

## Unintended Token Consumption

Claude Code consumes approximately 15% to 20% of user tokens through an automated background process. Every 30 seconds, background agents transmit their entire transcript to the model to generate a brief status update. This behavior, enabled by default since version 2.1.232, significantly impacts rate-limit headroom for active development sessions.

## Detection via OpenTelemetry

The anomaly was identified by analyzing OpenTelemetry exports, specifically grouping claude_code.api_request events by query_source. Data revealed that the agent_summary process often exceeded the cost of primary user conversations. Independent measurements across multiple users confirmed that these background requests account for 18% to 26% of total token usage in Claude Code.

## Technical Mechanism of Suppression

Since the Claude Code binary is precompiled Bun bytecode, standard JavaScript editing is ineffective. The solution utilizes a Bun preload script that wraps setTimeout and setInterval functions. By detecting specific summarizer anchors within callback source text, the hook returns an inert handle, effectively suppressing the timer without modifying the binary itself.

## Implementation and Configuration

Users can implement the fix by setting the BUN_OPTIONS environment variable to include the preload script. This requires defining the absolute path to the no-agent-summary.js file in shell configuration files like .bashrc or .zshrc. A daemon restart is mandatory to ensure all background processes inherit the new environment configuration.

## Verification and Monitoring

Verification is performed by setting the CC_AGENT_SUMMARY_LOG environment variable to track preload activity. After restarting the daemon, users should observe the log confirming the active mode. Successful suppression is validated when OpenTelemetry query_source values for agent_summary drop to zero, ensuring the agent panel status no longer triggers model calls.

## Limitations and Risks

The hook relies on matching specific source text anchors within timer callbacks. If future Claude Code updates alter these internal strings, the hook will fail silently, and summaries will resume. Furthermore, modifying client runtime behavior may conflict with service terms, placing the responsibility for compliance and potential account actions on the user.

## Evolution of Agent Summaries

The feature has evolved significantly since its introduction in early 2026. Initially a dead code path, it became an SDK opt-in by March before defaulting to 'on' in August. By October 2026, version 2.1.310 introduced a cheaper 'short mode' for summaries, though the default remains the full transcript transmission.

## Server-Side Control Dynamics

The summary interval is governed by server-side flags, typically ranging between 30 and 240 seconds. While the SDK provides an agentProgressSummaries option, it defaults to true in the compiled bundle, rendering standard configuration ineffective. The current workaround is necessary because no official environment variable exists to disable these non-essential model calls.

## Impact on Development Workflow

Disabling agent summaries provides immediate relief for users hitting rate limits during intensive coding tasks. While the agent panel status stops updating, core functionality remains intact. This optimization demonstrates the necessity of monitoring internal telemetry to manage costs when using AI-driven development tools that perform frequent, hidden background operations.

## Sources covering this story

- https://gist.github.com/flamerix-ai/c3905705cc4205e5de3011fa2e74efce — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
