← Back to PRs

#19707: fix(agents): apply per-agent skills filter to all run paths

by mcaxtr open 2026-02-18 03:25 View on GitHub →
agents size: M experienced-contributor
## Summary - Thread `resolveAgentSkillsFilter()` through the embedded runner attempt, compaction, and auto-reply command system-prompt paths so that agents with a configured `skillsFilter` only see their allowed skills in prompts and env overrides - Add `skillFilter` parameter to `resolveSkillsPromptForRun()` and `buildWorkspaceSkillSnapshot()` so downstream callers can pass a per-agent allowlist - Prefer explicit `agentId` over session-key derivation when resolving the skill filter in `runEmbeddedAttempt`, matching the existing `hookAgentId` fallback order - Rename test files from `.e2e.test.ts` to `.test.ts` so they're picked up by vitest, and add 18 unit tests covering filter resolution, snapshot building, and prompt generation ## Test plan - [x] `resolveAgentSkillsFilter` returns configured allowlist per agent and `undefined` when unconfigured - [x] `buildWorkspaceSkillSnapshot` filters skills and prompt content when `skillFilter` is provided - [x] `resolveSkillsPromptForRun` respects `skillFilter` for both snapshot and entry-based paths - [x] All 18 tests pass via `vitest run` - [x] `pnpm build && pnpm check` clean Closes #10546 <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR threads the per-agent `skillsFilter` through the three remaining run paths that were previously missing it: the embedded runner attempt, the compaction path, and the auto-reply commands system prompt. The changes are consistent and correct: - In `attempt.ts`, the agent ID is resolved with the same fallback order as the existing `hookAgentId` (prefer explicit `agentId` param, then derive from `sessionKey`). - In `compact.ts`, which lacks an `agentId` param, it correctly falls back to `resolveSessionAgentIds` from `sessionKey`. - In `commands-system-prompt.ts`, the `sessionAgentId` resolution was moved earlier so the `skillFilter` can be passed to `buildWorkspaceSkillSnapshot`. - The `resolveSkillsPromptForRun` and `buildWorkspaceSkillSnapshot` APIs gained a `skillFilter` parameter for callers to pass per-agent allowlists. - Test files were renamed from `.e2e.test.ts` to `.test.ts` to be picked up by vitest, and 18 new unit tests were added covering the filter resolution, snapshot building, and prompt generation. <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — it correctly threads skill filtering through all run paths with no behavioral regressions. - Score of 4 reflects clean, focused changes that correctly propagate the per-agent skill filter to all three previously-unfiltered paths. The snapshot path was already handling filters correctly at the construction site. No logic errors found. Minor redundant double-filtering is idempotent and harmless. Good test coverage with 18 new unit tests. Only reason it's not 5 is the minor code redundancy in how entries are pre-filtered then the same filter is passed again downstream. - No files require special attention — the production code changes in attempt.ts, compact.ts, and commands-system-prompt.ts are all consistent and well-tested. <sub>Last reviewed commit: d9cf6ae</sub> <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) <!-- /greptile_comment -->

Most Similar PRs