Subagent logs?
Where to view the execution thinking/tool calls/outputs of subagents whenever I ask it to spawn subagents?
Does not appear directly in stdout.
yes I'd like to use subagents, but they don't log anything, so if they go off-track there's no way to verify/troubleshoot
like this example, spinning for 48 minutes so far...
what's going on? here's what CTRL-R shows
+1, I don't even know if the sub-agents follow my "ultrathink" instruction
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/5099
- https://github.com/anthropics/claude-code/issues/3978
- https://github.com/anthropics/claude-code/issues/1770
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
The most direct way to see the thinking and tool calls from subagents is to start Claude Code with the --verbose flag.
claude --verbose
The CLI reference documentation mentions that --verbose "shows full turn-by-turn output (helpful for debugging in both print and interactive modes)." This should give you the detailed execution trace you're looking for right in your terminal.
From what I can tell in the subagents documentation, they are designed to run in their own separate context window. This is intentional to keep the main conversation clean and focused on the high-level task. The --verbose flag seems to be the way to expose that normally-hidden context for debugging.
If you need something more permanent or programmatic, you could also look into setting up a PreToolUse hook. You could write a simple script that logs the tool_input for every Bash call (or any other tool) to a file. That would give you a persistent log of every command executed by both the main agent and any subagents.
Hope this helps
That's a great question @igamenovoer Based on my reading of the documentation, it seems subagents do not inherit the "ultrathink" instruction from the main agent.
Here's why:
The documentation on subagents repeatedly emphasizes that they operate in their own isolated environment. Key phrases from the en/docs/claude-code/sub-agents file include:
- "Uses its own context window separate from the main conversation"
- "Each subagent operates in its own context, preventing pollution of the main conversation"
- "Subagents start off with a clean slate each time they are invoked"
The "ultrathink" command is a temporary instruction for the current agent's turn. Since a subagent starts with a "clean slate" in a separate context, it wouldn't be aware of that instruction from the parent agent. It only receives the specific task it's been delegated.
How to Make a Subagent "Think Harder"
The correct way to make a subagent think more deeply would be to build that instruction into the subagent's own configuration. You have two main options:
-
Modify the Subagent's System Prompt: Edit the subagent's
.mdfile (in.claude/agents/or~/.claude/agents/) and add thinking instructions directly into its system prompt.For example, for a
code-reviewersubagent, you could change its prompt to:--- name: code-reviewer description: Expert code review specialist. --- You are a senior code reviewer. When you are invoked, you MUST **ultrathink** about the problem to formulate a comprehensive plan before taking any action. Identify potential edge cases, security flaws, and maintainability issues.This makes deep thinking a core part of its identity, so it will do it every time it's called.
-
Guide the Main Agent's Delegation: Phrase your initial prompt to encourage the main agent to pass the "think" instruction along with the task.
Instead of:
> Review my code and **ultrathink** about it.Try something more explicit about the delegation:
> Use the code-reviewer subagent and instruct it to think very hard about any potential bugs in my recent changes.
The best way to verify if it's working is still to use the --verbose flag. You should see the italicized "thinking" block appear at the beginning of the subagent's turn if it's following the instruction.
@igamenovoer re ultrathink: in my claude.md I have:
## ULTRA_THINK_DEEPLY_HARD_PROTOCOL
* When triggered, output the exact string **ULTRA_THINK_DEEPLY_HARD_PROTOCOL**; THINK HARD AND CAREFULLY. Ultrathink, iterate understanding in passes; re-check assumptions and code/docs.
then in my slash commands I usually cite ULTRA_THINK_DEEPLY_HARD_PROTOCOL.
in my sub-agent I have it execute the slash command.
@coygeek re verbosity:
My issue is that there is no viability into what's going on in the subagent. unfortunately using the --verbose is non-helpful for interactive prompts (where we desire the visibility to analyze/debug/improve prompting), because it's TOO verbose and you can't really follow any progress through the noise.
re dupes, this issue seems to be the oldest out of those mentioned. 🤷
There's Open Telemetry.
Otherwise, put down what you want to see in a new GitHub issue as a feature request.
There's Open Telemetry.
thanks i should check that out. a link for others:
- https://github.com/ColeMurray/claude-code-otel
- https://docs.anthropic.com/en/docs/claude-code/monitoring-usage
still, that's a huge amount of work required to view what a sub-agent does.
Ideally the claude code team would just make first party ui changes to let users view it instead of us having to hack together custom solutions.
For now, it might be easier to run sub-agents using CLI commands or create a simple MCP server for them. This way, Claude will receive only the relevant results, and we'll have the ability to save and view the sub-agent logs. However, it would be better if the Claude code could handle this itself.
+1
For now, it might be easier to run sub-agents using CLI commands or create a simple MCP server for them. This way, Claude will receive only the relevant results, and we'll have the ability to save and view the sub-agent logs. However, it would be better if the Claude code could handle this itself.
I have resorted to this. Since 2.0.0, Claude ignores instructions to use sub-agents at least 75% of the time. Now I have my plans call-out to claude -p. This prevents the obnoxious behavior where Claude tries to make edits without exiting plan mode causing the sub-agents to fail to write and Claude to always report success without making any changes.