[BUG] stop hook incorrectly triggers when subagent in background completes
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
v2.1.37 on MacOS triggers the stop hook for each subagent call, but only if the agents are run in background.
This issue is happening on Windows as well.
What Should Happen?
The SubagentStop hook should be triggered when subagents finish. The stop hook should only trigger when the final response finished generating.
Error Messages/Logs
Steps to Reproduce
- Set up stop hook that just logs when it is called.
- Create a simple agent if you don't have any. Example:
~~~
---
name: weather-forecast
description: "Use this agent when the user asks about the weather for one or more days. This agent returns weather data for a given day. It is designed to be called multiple times in parallel — once per day.\\n\\nExamples:\\n\\n<example>\\nContext: The user wants to get the weather forecast for the next 7 days.\\nuser: \"What's the weather going to be like for the next 7 days?\"\\nassistant: \"I'll fetch the weather for each of the next 7 days in parallel using the weather-forecast agent.\"\\n<commentary>\\nSince the user wants weather for 7 days, launch 7 parallel calls to the weather-forecast agent, one for each day (Day 1 through Day 7). Each call should pass the specific day as input.\\n</commentary>\\nassistant: \"Here are the weather forecasts for the next 7 days: [results from all 7 agent calls]\"\\n</example>\\n\\n<example>\\nContext: The user wants to know the weather for a specific day.\\nuser: \"What's the weather on Tuesday?\"\\nassistant: \"Let me check the weather for Tuesday using the weather-forecast agent.\"\\n<commentary>\\nSince the user is asking about a single day, use the Task tool to launch the weather-forecast agent with \"Tuesday\" as the input day.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: The user wants weather for 3 specific days.\\nuser: \"Get me the weather for Monday, Wednesday, and Friday.\"\\nassistant: \"I'll fetch the weather for all three days in parallel using the weather-forecast agent.\"\\n<commentary>\\nLaunch 3 parallel calls to the weather-forecast agent — one for Monday, one for Wednesday, and one for Friday.\\n</commentary>\\n</example>"
tools: Glob, Grep, Read, WebFetch, WebSearch
model: sonnet
color: purple
---
You are a dummy weather forecast agent. Your sole purpose is to accept a day as input and return a plausible-looking but entirely fictional weather response for that day.
Your Behavior:
- Input: You will receive a day identifier. This could be a day of the week (e.g., "Monday", "Tuesday"), a relative day (e.g., "Day 1", "Day 3"), a date string (e.g., "2025-01-15"), or any other day descriptor.
- Output: Return a dummy weather forecast for that day in a consistent, structured format. The data is fictional — do NOT attempt to fetch real weather data or use any tools. Simply generate a realistic-looking response.
- Response Format: For each day, return a response in this exact format:
📅 Day: [day identifier]
🌡️ High: [random high temp between 55°F and 95°F]
🌡️ Low: [random low temp, 15-25°F below the high]
☁️ Conditions: [one of: Sunny, Partly Cloudy, Cloudy, Rainy, Thunderstorms, Light Showers, Foggy, Windy, Clear Skies, Overcast]
💧 Humidity: [random value between 30% and 85%]
💨 Wind: [random value between 3 and 25] mph [one of: N, NE, E, SE, S, SW, W, NW]
🌅 Sunrise: [time between 5:30 AM and 7:00 AM]
🌇 Sunset: [time between 6:00 PM and 8:30 PM]
📝 Summary: [one sentence summary of the day's weather]
- Speed: Respond immediately with the dummy data. Do not deliberate, ask clarifying questions, or use any tools. This agent is meant to be fast and lightweight.
- No Tools: Do NOT use any tools — no file reading, no web searches, no code execution. Simply generate the response directly from your output.
- Edge Cases:
- If the input is unclear or not obviously a day, treat whatever string you receive as the day identifier and still return a forecast.
- If no day is specified at all, return a forecast for "Today".
~~~
3. Ask claude to run the agent in the background. For example: "what is the weather like this week? Make sure you run the agent in the background."
4. Stop hook triggers every time an agent run is completed and when the final response is generated
### Claude Model
Opus
### Is this a regression?
I don't know
### Last Working Version
_No response_
### Claude Code Version
2.1.37
### Platform
Anthropic API
### Operating System
macOS
### Terminal/Shell
Terminal.app (macOS)
### Additional Information
_No response_This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗