fix(core,agent-tools): fix blocking I/O in load_instructions and add unit tests#3854
Merged
Merged
Conversation
…unit tests Wrap `load_instructions` with a `load_instructions_async` shim that runs the synchronous filesystem I/O on Tokio's blocking thread pool via spawn_blocking. Update the two async call sites (runner.rs startup and agent/mod.rs hot-reload watcher) to await the async variant. The sync function is preserved unchanged for the remaining non-async call site in provider_cmd.rs. JoinError from spawn_blocking is now logged via tracing::error instead of silently swallowed. Add 25 unit tests to zeph-agent-tools covering previously untested modules: channel.rs (11 tests: ToolEventStart/ToolEventOutput construction and Copy semantics, ChannelSinkError Display), error.rs (8 tests: ToolDispatchError variants, Display and From conversions), doom_loop.rs (7 tests: hash determinism, tool_use normalization, unclosed brackets, multi-marker sequences, passthrough). Crate test count grows from 4 to 29. Closes #3829 Closes #3836
3d4ab64 to
d1deb3a
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
perf(core): load_instructions performs blocking I/O on Tokio worker thread in async fn run() #3829:
load_instructionsperformed synchronous filesystem I/O (canonicalize,File::open,read_to_string) directly on a Tokio worker thread. Addedload_instructions_asyncwrapper usingtokio::task::spawn_blocking; updated the two async call sites (runner.rsstartup andagent/mod.rshot-reload watcher).JoinErroris now logged viatracing::errorinstead of silently swallowed. The sync function is preserved for the remaining non-async call site inprovider_cmd.rs.test(agent-tools): zeph-agent-tools has only 4 unit tests — doom_loop, channel, error, sealed modules untested #3836:
zeph-agent-toolshad only 4 unit tests covering trivial checks. Added 25 tests across three previously untested modules:channel.rs(11),error.rs(8),doom_loop.rs(7). Crate test count grows from 4 to 29.Test plan
cargo nextest run -p zeph-core --lib— 1418 passcargo nextest run -p zeph-agent-tools --lib— 29 passcargo nextest run --workspace --lib --bins— 9304 passcargo +nightly fmt --check— cleancargo clippy --workspace -- -D warnings— cleanCloses #3829
Closes #3836