Repository navigation
fix(agent): flush buffered Responses parts from the first part - #7556
Open
garvit-arora wants to merge 1 commit into
Open
garvit-arora wants to merge 1 commit into
garvit-arora wants to merge 1 commit into
Conversation
The coalesced-closure timer was recreated after every stream event, so a provider that emits events less than 25 ms apart never wrote completed parts. A crash in that window left no persisted part and recovery blocked the Run. Anchor the 25 ms deadline to the first buffered part instead. Generated-by: DeepSeek V4.1 Flash Free (OpenCode)
This branch has not been deployed
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
Since #7427,
receive()writes buffered completed Responses parts only after 25 ms without a stream event. Because thetokio::time::sleep(25 ms)was created again on every loop iteration, a provider that emits events less than 25 ms apart never wrote anything: a completed text part followed by a long tool-argument stream stayed in memory until the stream ended.If the Host died in that window, the next start found no persisted part for the attempt and
assess_recoveryblocked the Run. The issue's measurements show 10 ms and 20 ms event gaps never writing, while 40 ms gaps wrote after about 85 ms.This anchors the flush deadline to the first buffered part instead of restarting it after every event, matching the local experiment in the issue. The deadline is cleared when the buffer drains, so a later batch gets its own 25 ms window.
Fixes #7477
Verification
cargo check -p maka-agent-native --lib --locked— passed.cargo test -p maka-agent-native --lib coalesced_flush --locked— 1 passed. The test asserts the deadline is anchored to the first buffered part and does not move when later events arrive.cargo fmt --all -- --check— passed.I did not run the mock Responses SIGKILL reproduction from the issue (macOS/WebSocket fixture); CI covers the crate build and tests.
AI use
Select exactly one:
Tool(s) and scope: DeepSeek V4.1 Flash Free via OpenCode implemented the deadline change and its unit test.
Checklist
Does this PR entail a breaking change or persisted-data migration?
upgrade_compat.rscoverage under Summary aboveDoes this PR entail a change in behavior?