Subagent logs?

Resolved 💬 19 comments Opened Jun 28, 2025 by cktang88 Closed Jan 18, 2026

Where to view the execution thinking/tool calls/outputs of subagents whenever I ask it to spawn subagents?

View original on GitHub ↗

19 Comments

cktang88 · 1 year ago

Does not appear directly in stdout.

jasonswearingen · 11 months ago

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

jasonswearingen · 11 months ago

like this example, spinning for 48 minutes so far...

<img width="1524" height="366" alt="Image" src="https://github.com/user-attachments/assets/539411e8-13a5-409e-b45e-a481f9159855" />

what's going on? here's what CTRL-R shows

<img width="1140" height="283" alt="Image" src="https://github.com/user-attachments/assets/4c48d891-8fab-465f-97ae-a80e39ffa72e" />

igamenovoer · 11 months ago

+1, I don't even know if the sub-agents follow my "ultrathink" instruction

github-actions[bot] · 11 months ago

---

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5099
  2. https://github.com/anthropics/claude-code/issues/3978
  3. 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

coygeek · 11 months ago

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

coygeek · 11 months ago

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:

  1. Modify the Subagent's System Prompt: Edit the subagent's .md file (in .claude/agents/ or ~/.claude/agents/) and add thinking instructions directly into its system prompt.

For example, for a code-reviewer subagent, you could change its prompt to:
``markdown
---
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.

  1. 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.

jasonswearingen · 11 months ago

@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. 🤷

coygeek · 11 months ago

There's Open Telemetry.

Otherwise, put down what you want to see in a new GitHub issue as a feature request.

jasonswearingen · 11 months ago
There's Open Telemetry.

thanks i should check that out. a link for others:

still, that's a huge amount of work required to view what a sub-agent does.

cktang88 · 11 months ago

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.

AmirL · 10 months ago

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.

glidea · 9 months ago

+1

cruftyoldsysadmin · 8 months ago
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.

github-actions[bot] · 7 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.

gastonmorixe · 7 months ago

yes it does

github-actions[bot] · 5 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 · 5 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] · 5 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.