Skip to content

fix(agent): key the skills cache on the resolved skill directories - #1605

Merged
huichen merged 1 commit into
mainfrom
pr/huichen
Nov 13, 2026
Merged

huichen merged 1 commit into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

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 redirects HOME to 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 made rpc::session_prompt::tests::current_system_prompt_matches_what_a_run_sends see # Available Skills in 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 — SkillsCacheEntry carries its expanded roots; 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.

Verification

Local, on the branch tip 18057dd13 in a detached worktree, rustc pinned to 1.99.1 (rust-toolchain.toml), ulimit -n 8192, CARGO_TARGET_DIR shared with the main checkout:

  • cargo fmt --all -- --check → clean
  • cargo clippy -p future-agent --all-targets -- -D warnings → clean
  • cargo test -p future-agent --lib skills → 96 passed, 0 failed
  • cargo test -p future-agent --lib → 3075 passed, 5 failed, 7 ignored. All 5 failures are in agent/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 at origin/main in 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 18057dd13 to restore the previous (home-agnostic) cache keying.

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.
@huichen
huichen enabled auto-merge (squash) November 13, 2026 23:20
@huichen
huichen merged commit ea70ae5 into main Nov 13, 2026
48 of 50 checks passed
@huichen
huichen deleted the pr/huichen branch November 13, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant