claude-code
claude-code copied to clipboard
Skill tool PostToolUse response returns incorrect agentId
Bug Description
When a Skill tool completes and fires a PostToolUse hook event, the tool_response.agentId field contains an ID that doesn't match the actual subagent transcript file created on disk.
Steps to Reproduce
- Invoke a Skill tool (e.g.,
committing-changes) - Capture the
PostToolUsehook event - Compare
tool_response.agentIdwith the actual subagent transcript file in~/.config/claude/projects/<project>/<session_id>/subagents/
Expected Behavior
The agentId in the PostToolUse response should match the subagent transcript filename (e.g., if response has agentId: "ae2fbc4", there should be a file agent-ae2fbc4.jsonl).
Actual Behavior
The agentId in the response doesn't match any transcript file:
-
PostToolUse response:
agentId: "ae2fbc4" -
Actual transcript file created:
agent-a674f5e.jsonl
Evidence
Task tools work correctly - the agentId matches:
| Tool | Response agentId | Transcript File | Match |
|---|---|---|---|
| Task | aa94c92 | agent-aa94c92.jsonl | ✅ |
| Task | abbcbfa | agent-abbcbfa.jsonl | ✅ |
| Skill | ae2fbc4 | agent-a674f5e.jsonl | ❌ |
PostToolUse Event Data (Skill)
{
"hook_event_name": "PostToolUse",
"tool_name": "Skill",
"tool_use_id": "toolu_01SKyuBnaNn9aN23NuuTXC8p",
"tool_input": {
"skill": "committing-changes"
},
"tool_response": {
"status": "forked",
"agentId": "ae2fbc4",
"commandName": "committing-changes"
}
}
Impact
This breaks any tooling that tries to correlate subagents with their triggering Skill invocations using the agentId from hook events.
Environment
- Claude Code CLI
- macOS