fix(agentic): flush persisted tool result before returning#881
Merged
GCWing merged 1 commit intoMay 28, 2026
Conversation
tokio::fs::File buffers writes and does not guarantee a flush on drop, so a subsequent synchronous read could observe an empty/partial file. This caused an intermittent macOS CI failure in bash_full_output_persists_even_when_assistant_text_is_already_truncated. Add an explicit flush() after write_all so persisted output is visible to later readers. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
tool_result_storage::write_once在 tokiowrite_all之后未flush()。tokio::fs::File缓冲写入且 drop 时不保证刷盘,导致后续同步std::fs::read_to_string可能读到空/不完整文件。file.flush().await,保证缓冲数据落到底层 std File(OS 页缓存)。影响
agentic::tools::tool_result_storage::tests::bash_full_output_persists_even_when_assistant_text_is_already_truncated(left: ""vsright: "xxxx...")。write_once返回后立即读取持久化文件的代码都可能拿到空内容。这里只是 macOS 时序更容易触发。Test plan
cargo test -p bitfun-core bash_full_output_persists_even_when_assistant_text_is_already_truncated通过cargo test -p bitfun-core tool_result_storage(模块全量,6 passed)通过Notes
发现自 PR #846 的 macOS CI,根因与该 PR 无关,故拆出来单独提交。
🤖 Generated with Claude Code