fix(s08): flush background task results before agent loop exits#49
Open
sirhappy wants to merge 1 commit intoshareAI-lab:mainfrom
Open
fix(s08): flush background task results before agent loop exits#49sirhappy wants to merge 1 commit intoshareAI-lab:mainfrom
sirhappy wants to merge 1 commit intoshareAI-lab:mainfrom
Conversation
When the LLM decides it has no more work to do (stop_reason != "tool_use"), the agent loop exited immediately, silently dropping any background task results that arrived during or after the final LLM call. The fix adds a final drain step at the exit point of agent_loop in both s08_background_tasks.py and s_full.py: 1. Drain any notifications that completed while the LLM was responding. 2. If tasks are still running, wait up to MAX_BG_WAIT (30s) for them to finish, then drain again. 3. If there are pending results, inject them and continue the loop so the LLM can acknowledge them before the session ends. Fixes shareAI-lab#46
|
@sirhappy is attempting to deploy a commit to the crazyboym's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #46.
In
s08_background_tasks.py(ands_full.py), theagent_loopexits immediately whenstop_reason != "tool_use". Any background task results that arrive during the final LLM call, or from tasks that are still running at that point, are silently dropped — the notification queue is never drained again.Minimal reproduction:
background_run("sleep 5 && echo done")).end_turn.Fix
At the exit branch (
stop_reason != "tool_use") inagent_loop, before returning:MAX_BG_WAIT(30 s) for them to finish, then drain again.<background-results>message andcontinueso the LLM can acknowledge them before the session ends.The same fix is applied to
s_full.pywhereBackgroundManageris also used.Files changed
agents/s08_background_tasks.pyimport time,MAX_BG_WAITconstant, final-drain logic inagent_loopagents/s_full.pyMAX_BG_WAITconstant, same final-drain logic inagent_loop