Background sidechain agents consuming tokens without returning results
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
- Start a new Claude Code session in any project
- Monitor the
~/.claude/projects/{project}/*.jsonlfiles for newagent-*.jsonlfiles - 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 consumedagent-9845a4a3.jsonl: 3,831 input tokens consumed
These agents:
- Are marked as
isSidechain: true- NOT part of main conversation thread - Have
stop_reason: nulland only 1 output token - never completed - Generate responses mentioning tool calls, but these aren't actual
tool_useblocks - Results are NEVER fed back to the main conversation
Expected Behavior
Either:
- Background agents should have their results retrieved via
AgentOutputTooland integrated into the main conversation - 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.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗