fix(agents): collapse repeated waits queued inside one model turn - #979
Merged
Conversation
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
Greptile SummaryThe PR prevents multiple
Confidence Score: 5/5The PR appears safe to merge, with the wait deduplication aligned to the model-turn lifecycle and no actionable regressions identified. Supported execution paths share the hook-mutated context with agent tools, repeated waits collapse only within one model turn, and later turns continue to perform real waits. Important Files Changed
Reviews (1): Last reviewed commit: "fix(agents): state that one wait is enou..." | Re-trigger Greptile |
devin-ai-integration
Bot
force-pushed
the
devin/1785961358-dedupe-waits
branch
from
August 5, 2026 20:35
0a74eb0 to
d25644e
Compare
0xallam
force-pushed
the
devin/1785961358-dedupe-waits
branch
from
August 5, 2026 21:06
d25644e to
905b7bb
Compare
0xallam
force-pushed
the
devin/1785961358-dedupe-waits
branch
from
August 5, 2026 21:07
905b7bb to
cae37fc
Compare
0xallam
force-pushed
the
devin/1785961358-dedupe-waits
branch
from
August 5, 2026 21:07
cae37fc to
99baead
Compare
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.
Summary
Stacked on #978 → #977 → #976, so review those first.
wait_for_agentsblocks and resumes on its own, but nothing says so, so a model treats it as a poll and writes the whole loop out ahead of time —wait → view_agent_graph → wait → ...— in one response. Every queued wait then parks for its full timeout in turn, so an orchestrator can sit on hundreds of consecutive no-op waits (at the 300s ceiling, hours) while its children run unsupervised. The per-response cap (#977) bounds how many get queued; this bounds what they cost.Only the first wait of a model turn parks.
ReportUsageHooks.on_llm_startstamps the turn onto the run context, and the tool records the turn it waited in:Keying on the model turn is what makes this safe: waits the model queued blindly inside one response collapse, while a wait it issues after seeing the previous result — a new turn — parks normally. No timing heuristics, no "identical arguments" matching. The collapsed response tells the model why, so it can react instead of re-queueing.
Prompt side, in the shared
INTER-AGENT MESSAGESblock (so every variant gets it — root and subagent, autonomous and interactive) plus the tool's own summary:Verified by assembling the real prompt across root/subagent × autonomous/interactive × quick/standard/deep × whitebox — all 24 variants carry the line, and it is in the tool description the SDK sends.
Repro
tests/test_wait_dedupe.pydrives the real tool against a realAgentCoordinator(timeout shrunk to 2s; the shape is identical at 300s):Plus: a wait in the next turn still parks, a message arriving during the first wait is still reported, and
on_llm_startbumps the turn marker.Link to Devin session: https://app.devin.ai/sessions/dad023e379e942f287bcf6822463b7a4
Requested by: @0xallam