Background sidechain agents consuming tokens without returning results

Status Closed — not planned
Maintainer reply None cached
Activity 5 comments · opened Dec 7, 2025 · closed Feb 9, 2026

Bug Description

When starting a new Claude Code session, background \"sidechain\" agents are spawned that consume input tokens but their results are never returned to the main conversation.

Environment

  • Claude Code Version: 2.0.61
  • OS: Linux (Ubuntu)
  • Model: Claude Opus 4.5

Steps to Reproduce

  1. Start a new Claude Code session in any project
  2. Monitor the ~/.claude/projects/{project}/*.jsonl files for new agent-*.jsonl files
  3. Observe that multiple agent files are created immediately on session start

Observed Behavior

When starting a session, multiple agent-*.jsonl files are created with the following characteristics:

{
  "isSidechain": true,
  "sessionId": "96e08ed5...",  // Same as main session
  "output_tokens": 1,
  "stop_reason": null
}

Example from actual session:

  • agent-cb4ad2c6.jsonl: 3,703 input tokens consumed
  • agent-9845a4a3.jsonl: 3,831 input tokens consumed

These agents:

  1. Are marked as isSidechain: true - NOT part of main conversation thread
  2. Have stop_reason: null and only 1 output token - never completed
  3. Generate responses mentioning tool calls, but these aren't actual tool_use blocks
  4. Results are NEVER fed back to the main conversation

Expected Behavior

Either:

  1. Background agents should have their results retrieved via AgentOutputTool and integrated into the main conversation
  2. OR these agents should not be spawned if their results won't be used

Impact

  • Token waste: ~7,500+ input tokens per session start with zero value
  • Cost: Unnecessary API costs for users
  • Confusion: Activity appears in JSONL logs but not in the UI

Evidence

Agent content shows responses like:

"I'll start by getting recent context from my memory system..."
"I'm in READ-ONLY mode, so I can..."

But these are just text responses - no actual tool execution occurs, and the "context" gathered is discarded.

Additional Context

Discovered while building a JSONL file watcher to monitor Claude Code activity. The watcher showed multiple NEW SESSION [agent-*] entries being created on every session start, with responses that never appeared in the main conversation UI.

View original on GitHub ↗

5 Comments

github-actions[bot] · 9 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

Fieldnote-Echo · 9 months ago

Still experiencing this issue on Claude Code 2.1.2 (native install, Linux).

Every user message spawns a new agent-*.jsonl sidechain file. On a typical session, this creates 50+ files in minutes. Each file consumes ~3-4K input tokens that produce no useful output (stop_reason: null, 1 output token).

Current workaround: cron job to delete agent-*.jsonl files periodically.

Request: Please add a configuration option to disable sidechain spawning, or fix the excessive spawning behavior. The isSidechain: true marker is helpful for filtering in third-party UIs, but the root cause (spawning on every message) should be addressed.

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 8 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.