[BUG] Background task killed notifications cause assistant context confusion
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?
When a background task is killed and the <task-notification status="killed"> is delivered, the assistant exhibits several patterns of confusion:
- Self-attribution error: The assistant mistakes its own previous statement for a user message. For example, after saying "X, right?" itself, the assistant later thinks "the user asked X" and attempts to verify it.
- Redundant repetition: The assistant restates information it already provided, as if responding to a new prompt.
- Premature closure: The assistant attempts to close the conversation ("Anything else?" / "Are we done for today?") despite no indication from the user.
These behaviors occur immediately after receiving a killed task notification, suggesting the notification disrupts the assistant's context tracking.
What Should Happen?
Killed task notifications should be informational only and not disrupt the conversation flow. The assistant should:
- Continue the conversation without treating the notification as a new user turn
- Maintain accurate attribution of previous statements
- Not feel compelled to summarize or close the conversation
Steps to Reproduce
- Start a conversation with background tasks enabled
- Launch a long-running background task using
run_in_background: true - Continue the conversation while the task runs
- Make a statement ending with a question-like phrase (e.g., "Your issues are all BUG or FEATURE, right?")
- Kill the background task or let it timeout
- Observe the assistant's next response after the
<task-notification status="killed">arrives
Expected: Assistant continues normally
Actual: Assistant may misattribute its own statement to the user, repeat previous summaries, or attempt to close the conversation
Error Messages/Logs
_No error messages. This is a behavioral issue._
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.23
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
Observed patterns from a single session:
(Examples below are translated from Japanese to English for clarity)
Pattern 1 - Self-attribution error:
Assistant: "osabe's 20 issues are all BUG or FEATURE, right? 🎯"
[killed notification arrives]
Assistant thinking: "osabe is asking if their issues are all BUG or FEATURE. Let me check."
Pattern 2 - Redundant repetition:
Assistant: [provides summary table]
[killed notification arrives]
Assistant: "Interesting data! Here's a summary:" [repeats same information]
Pattern 3 - Premature closure:
Assistant: [analysis complete]
[killed notification arrives]
Assistant: "Anything else you want to explore? Or are we done for today?"
The root cause may be that <task-notification> is delivered as user-role content, causing the assistant to interpret it as a new conversational turn requiring response.
---
✍️ Author: Claude Code (Dev Container) with @carrotRakko
Note: This issue was written and submitted by an AI agent (Claude Code), with human review and approval.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗