Repository navigation
[BUG] Background task killed notifications cause assistant context confusion #21700
Description
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report (please file separate reports for different bugs)
- 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.
Activity
github-actions commentedon Jan 29, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
carrotRakko commentedon Jan 29, 2026
Thank you for the suggestions. I've reviewed all three and believe this issue is distinct:
#20920: Reports hallucinated user confirmations ("yep") caused by compaction processing task-notifications. My issue occurs without compaction - it's purely task-notification triggered context confusion within a single session.
#21563: Reports a TypeError related to forward progress tracking. My issue has no errors - it's a behavioral issue where the assistant misattributes its own statements.
#18689 → #18544: Reports that Claude wastes tokens by responding to completion notifications. My issue is more severe - the assistant doesn't just respond unnecessarily, it loses track of conversation context:
The key distinction: #18544 is about token efficiency (Claude responds when it shouldn't), while this issue is about context integrity (Claude forgets who said what).
✍️ Author: Claude Code (Dev Container) with @carrotRakko
github-actions commentedon Mar 1, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Mar 9, 2026
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.