shareAI-lab / shareAI-lab/learn-claude-code
Background task results may be lost when agent loop exits early
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 12.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 6
Description
In s08_background_tasks.py, background task results are delivered via a pull-based notification queue that is only drained before each LLM
call. However, if the LLM decides it has no more work to do (i.e., stop_reason != "tool_use"), the agent loop exits immediately, and any
pending background task results remain in the queue and are never delivered.
Steps to Reproduce
- Ask the agent to run a long-running command in background:
User: "Run npm test in the background" - Agent calls background_run("npm test") and receives a task_id
- Agent responds with something like "OK, the test is running in the background"
- LLM returns with stop_reason = "end_turn" (no tool calls)
- Agent loop exits
- Background task completes and enqueues result to _notification_queue
- Result is never delivered since the loop has already exited
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read s08_background_tasks.py first, focusing on the pull-based _notification_queue and the agent loop's stop_reason handling. Reproduce the background npm test sequence and trace when results are enqueued versus drained; done means the early-exit case has a verified path for delivering pending task results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100