fix(context,plugins): deterministic compression order and async fs (#4558, #4560)#4578
Merged
Conversation
…4558, #4560) - zeph-core: sort indices before building to_compress in select_messages_for_compression; HashSet iteration was non-deterministic, causing variable message order in the compression LLM prompt (closes #4558) - zeph-plugins: replace std::fs::write/read_to_string with tokio::fs equivalents in update_one_plugin to avoid blocking the Tokio thread pool during concurrent auto-update checks (closes #4560) Regression tests added for the compression ordering fix.
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
select_messages_for_compressioniterated a rawHashSet<usize>to buildto_compress, producing non-deterministic message order in the LLM compression prompt. Fixed by sorting indices before mapping to messages — mirrors the existing pattern inapply_compression_removals.update_one_plugincalledstd::fs::writeandstd::fs::read_to_stringdirectly on the Tokio executor after the mainspawn_blockingblock, risking thread pool starvation under concurrent auto-update checks. Replaced withtokio::fs::write(...).awaitandtokio::fs::read_to_string(...).await.Both fixes are minimal and targeted — no surrounding code was refactored.
Test plan
select_messages_for_compression_returns_chronological_orderandselect_messages_for_compression_excludes_pinnedselect_messages_for_compressionvisibility bumped topub(crate)to enable unit testingcargo nextest run -p zeph-core -p zeph-plugins --lib— 1617 tests passedcargo +nightly fmt --check— cleancargo clippy -p zeph-core -p zeph-plugins -- -D warnings— cleanorigin/mainCloses #4558
Closes #4560