fix: prevent deferred inference requests from starving the event loop#66
Draft
antra-tess wants to merge 1 commit into
Draft
fix: prevent deferred inference requests from starving the event loop#66antra-tess wants to merge 1 commit into
antra-tess wants to merge 1 commit into
Conversation
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
Root cause
When a new wake arrived while an agent was
streamingorwaiting_for_tools,processInferenceRequests()requeued it.processNextEvent()treated the non-empty request queue as progress and skipped its normal backoff. IfactiveStreamswas empty or stale at the same time, the loop had no macrotask yield at all.That microtask-only polling loop pinned Bun at 100% CPU and starved the tool-result and HTTP I/O needed to make progress. Sol remained
waiting_for_tools, while Fleet health probes timed out and reported the agent down.Impact
Deferred wakes can no longer turn an otherwise recoverable tool wait into a self-sustaining event-loop wedge. Tool results, Web UI health checks, Discord traffic, and timers continue receiving event-loop time while the wake remains queued.
Validation
npm run buildUP, Web UI HTTP 200, zero pending requests, and normal CPU