Repository navigation
fix(agent): key the skills cache on the resolved skill directories - #1605
Merged
Merged
Conversation
The process-global skills cache held a single (timestamp, skills) entry and ignored the directories that produced it, while `~` in those directories resolves through `$HOME` and `FUTURE_HOME`. A process whose home moved — a second instance, or a test that redirects HOME to install fake skills — was therefore served skills discovered under the previous home until the 60s TTL expired. That leaked across tests in the same binary: a home carrying fake skills seeded the entry, a later test's system prompt picked it up, and a rebuild of the same prompt (after an invalidation refreshed the entry under the test's own, skill-free home) could no longer reproduce it. On Windows CI that surfaced as `rpc::session_prompt::tests::current_system_prompt_matches_what_a_run_sends` seeing `# Available Skills` in the prompt a run sent and none in the prompt read back after the run. A cache entry now records the resolved roots it was built from, and a read reuses it only for exactly those roots; the refresh performs its I/O on the same resolved paths it keyed on, so an entry can never describe directories other than the ones it is served for. `discover_skills` resolves once and shares the path-based discovery. Regression test: `cached_discovery_does_not_serve_another_home` installs a skill under one test home, drops it, and asserts a skill-free home is not served the cached entry.
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.
The agent's process-global skills cache was keyed on nothing: one
(Instant, Vec<Skill>)entry for the whole process, while the skill roots expand~through$HOME/FUTURE_HOME. A process whose home moves — a second instance, or a test that redirectsHOMEto install fake skills — was served skills discovered under the previous home until the 60s TTL expired. On Windows CI that leaked across parallel tests in the same binary and maderpc::session_prompt::tests::current_system_prompt_matches_what_a_run_sendssee# Available Skillsin the prompt a run sent but not in the prompt rebuilt after it.A cache entry now records the resolved roots it was built from and is reused only for exactly those roots, and the refresh does its I/O on the same resolved paths it keyed on. This is the root-cause fix for a CI flake, not a product behaviour change.
Commits
fix(agent): key the skills cache on the resolved skill directories —SkillsCacheEntrycarries its expanded roots;discover_skillsresolves once and shares the path-based discovery; regression testcached_discovery_does_not_serve_another_homeinstalls a skill under one test home, drops it, and asserts a skill-free home is not served the cached entry.Verification
Local, on the branch tip
18057dd13in a detached worktree, rustc pinned to1.99.1(rust-toolchain.toml),ulimit -n 8192,CARGO_TARGET_DIRshared with the main checkout:cargo fmt --all -- --check→ cleancargo clippy -p future-agent --all-targets -- -D warnings→ cleancargo test -p future-agent --lib skills→ 96 passed, 0 failedcargo test -p future-agent --lib→ 3075 passed, 5 failed, 7 ignored. All 5 failures are inagent/src/sandbox(add_session_allow_maps_read_op,enabled_gates_writes_outside_workspace,session_allow_takes_effect,windows_plan::allow_write_rule_lands_in_writable_allow_read_does_not,windows_plan::writable_roots_are_minimized_by_ancestor), a module this commit does not touch; the same 5 fail atorigin/mainin a full parallel run and pass when the module runs alone (cargo test -p future-agent --lib sandbox::→ 225 passed, 0 failed here). Pre-existing and environmental, not this diff.CI is the backstop for the platform matrix (the flake this fixes was observed on Windows).
User-visible changes
None. The cache is internal to the agent; no setting, default, migration or wire change. Revert
18057dd13to restore the previous (home-agnostic) cache keying.