anthropics / anthropics/claude-code
Background task kill/completion notification wakes the session and re-reads full context -- costs a full turn with no user input
- Lingua principale
- Python
- Stelle
- 145k
- Fork
- 23.1k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
## Summary
When a session has a still-tracked background Bash task (`run_in_background: true`) and the
conversation has already ended (user said goodbye, no further input expected), a later
completion/kill notification for that task still wakes the session and triggers a full model
turn. That turn re-reads the entire conversation context and produces a reply, consuming real
usage, even though no user action occurred and nobody is present to read the reply.
## What happened
- Started a local dev server as a background Bash task mid-session, for iterative testing.
- Conversation concluded normally (user said goodbye, assistant said goodbye back).
- Hours later, the machine went to sleep and later woke; the background process was killed by
the OS for low memory.
- The resulting task-notification ("...was killed because the system is running low on
memory") arrived and re-invoked the model, which read back the entire (very long, all-day)
conversation and replied.
- The user's usage dropped by ~10% for this, despite having typed nothing since saying goodbye.
## Why this is surprising
- The notification is purely informational — nothing about it requires or benefits from a full
model turn, since there's no pending user request to serve.
- The cost of that turn scales with the size of the conversation (all-day session, in this
case), not with the size or importance of the notification.
- Nothing surfaces this cost in advance, or lets the user opt a visibly-ended session out of
"wake and react" behavior for background-task events.
## Suggested fixes (any one would help)
1. Let a session that has ended (last turn was a plain conversational close, no pending tool
state) suppress or defer background-task wake turns, surfacing them on the user's next real
input instead of spending a full turn immediately.
2. Don't require re-reading the *entire* transcript for a turn that's only reporting on an
unrelated background process finishing/dying.
3. Surface the estimated cost of a notification-driven turn before it runs (related to #92062's
point about per-turn cost being invisible).
## Environment
Claude Code, Windows 10. Long single-conversation session; background task launched via the
Bash tool's `run_in_background`.
Related: #92062 (background-task usage generally invisible/uncapped), #73440 (memory-pressure
reaper kills tasks silently) — this report is specifically about the *notification turn itself*
costing usage after the conversation had already ended, distinct from both.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
The payload identifies the Bash tool's run_in_background flow and its completion/kill notification as entry points; begin by tracing how those notifications wake a session after its final conversational turn. Done means an ended session no longer spends a full model turn on such an event, instead suppressing or deferring it until real user input, with the full transcript reread avoided or its cost addressed.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- bash, python
- Ambito
- cli, developer-experience, performance
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Attiva
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100