Repository navigation
Conversation
potiuk
left a comment
There was a problem hiding this comment.
Thanks, reading the transcript for the running skill is a neat way to catch a borrowed caller, and injected text can't fake a skill switch there. Before this can merge: a skill that runs another one first (security-issue-fix runs security-issue-sync) gets its own later writes refused, and the branch needs a rebase (only the generated fingerprint conflicts).
The branch currently conflicts with main and needs a rebase before this can merge.
nested-skill-false-refusal (tools/agent-guard/src/agent_guard/__init__.py:2571)
The running skill is the latest
Skilltool call, or slash command naming a skill, in the session transcript
skill = running_skill(transcript_path)
'Latest Skill call' is not 'the running skill' when one skill runs another and then continues. security-issue-fix says (plugins/magpie-security/skills/issue-fix/SKILL.md:134) "It always runs security-issue-sync first"; when the agent does that with the Skill tool, every later issue-fix write under its own --caller security-issue-fix (tracker update, rollup, labels) is refused, because the latest Skill call is now issue-sync, whose files name only security-issue-sync. The refusal then tells the agent to stop and ask for a policy grant the policy already has. This hits the main security pipeline, and no test covers an outer skill that resumes after an inner one. Allow the union of callers of every skill invoked since the last user turn (or the last N skills), not only the latest one; at minimum also accept the caller of the skill invoked just before the latest one. Add a test: transcript with Skill(issue-fix) then Skill(issue-sync), then a launch with --caller security-issue-fix must be allowed.
Smaller observations
tools/agent-guard/src/agent_guard/__init__.py—tools/spec-loop/specs/vetted-command-surface.mddescribes the sibling agent-guard rulesvetted-ops-spellingandvetted-ops-source. The newvetted-ops-callerrule, its fail-open cases and its hook-env-only override are not recorded there. Add the rule tovetted-command-surface.mdbeside the other two vetted-ops guards.- See inline comments on
tools/vetted-ops/README.md:149,tools/agent-guard/src/agent_guard/__init__.py:2446,tools/agent-guard/tests/test_vetted_caller.py:1.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. After you've
addressed the points above and pushed an update, an Apache Magpie
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.More on how Apache Magpie handles maintainer review:
Contributing guide.
| return None # the dispatcher itself refuses a launch with no caller | ||
| if _truthy(os.environ.get(GLOBAL_OFF_ENV)) or _truthy(os.environ.get(CALLER_OVERRIDE_ENV)): | ||
| return None | ||
| skill = running_skill(transcript_path) |
There was a problem hiding this comment.
nested-skill-false-refusal
The running skill is the latest
Skilltool call, or slash command naming a skill, in the session transcript
'Latest Skill call' is not 'the running skill' when one skill runs another and then continues. security-issue-fix says (plugins/magpie-security/skills/issue-fix/SKILL.md:134) "It always runs security-issue-sync first"; when the agent does that with the Skill tool, every later issue-fix write under its own --caller security-issue-fix (tracker update, rollup, labels) is refused, because the latest Skill call is now issue-sync, whose files name only security-issue-sync. The refusal then tells the agent to stop and ask for a policy grant the policy already has. This hits the main security pipeline, and no test covers an outer skill that resumes after an inner one. Allow the union of callers of every skill invoked since the last user turn (or the last N skills), not only the latest one; at minimum also accept the caller of the skill invoked just before the latest one. Add a test: transcript with Skill(issue-fix) then Skill(issue-sync), then a launch with --caller security-issue-fix must be allowed.
There was a problem hiding this comment.
Thanks, you're right. Fixed in d69e49f.
The rule now allows the callers of every skill invoked since the user's last prompt, plus the one that was running when that prompt came in. That second part keeps a skill's caller after the user answers a question the skill asked. A prompt that is itself a slash command naming a skill starts that skill alone. Tool results and isMeta messages don't count as a prompt.
Your case is test_an_outer_skill_keeps_its_caller_after_running_another: Skill(issue-fix) then Skill(issue-sync), and a launch with --caller security-issue-fix is allowed. There are also tests for the turn boundaries: a skill keeps its caller across the user's answers, a skill from an earlier turn expires, and a tool result doesn't start a turn.
There was a problem hiding this comment.
Same-turn nesting works now, but not when the user answers in between, which is how issue-fix runs issue-sync (issue-fix SKILL.md Step 1: "apply the state corrections the user confirms there"). Walking back from the confirmation, the first skill found is issue-sync, the loop stops (__init__.py, the if turn_began and skill: break), and issue-fix is no longer counted, so every later --caller security-issue-fix write is refused.
Suggest carrying every skill that was running across a prompt (stop only at a slash-command prompt or a fixed cap of turns): the guard catches accidental swaps only, so a wider set is a cheaper error than a false refusal in the security pipeline. Please add a test: Skill(issue-fix), tool result, Skill(issue-sync), tool result, prompt "yes, apply", then --caller security-issue-fix must be allowed; and update the README row and spec sentence to match.
There was a problem hiding this comment.
Thanks, agreed: a wider set is the cheaper mistake here. Fixed in 23537ce.
Every skill invoked across the user's last 10 prompts now counts. A prompt that is a slash command starting a skill still stops the walk, and nothing before it counts.
Your case is test_an_outer_skill_keeps_its_caller_after_the_user_confirms_the_inner_one: Skill(issue-fix), tool result, Skill(issue-sync), tool result, prompt "yes, apply", and --caller security-issue-fix is allowed. test_a_skill_expires_after_the_turn_cap pins the limit. The README row and the spec sentence say the same.
I also rebased on main, which now has vetted-op-tracker-batch and vetted-op-tracker-batch-unprompted (#2369). The rule already covered them, since it checks every vetted-op* entry point, and they're now in the docs and in a test. agent-guard suite: 915 passed.
71b488c to
d69e49f
Compare
…kill Review of apache#2352. The latest Skill call is not the running skill when one skill runs another and carries on: security-issue-fix runs security-issue-sync first, so its own later writes were refused. - Allow the callers of every skill invoked since the user's last prompt, plus the one running when it was sent (so a skill that asks the user a question keeps its caller). A prompt that is itself a slash command naming a skill starts that skill alone. Tool results and injected messages do not start a turn. - Recognise the magpie-<skills/ link> names that snapshot and self-adoption installs give their skills. - Say in both READMEs and the vetted-command-surface spec that the agent chooses its own Skill calls, so the rule catches an accidental caller swap, not a deliberate one. - test_vetted_caller.py is no longer executable. Generated-by: Claude Code (Opus 5.5)
|
Thanks for the review, @potiuk. All points are addressed in d69e49f:
agent-guard suite: 911 passed (30 in |
potiuk
left a comment
There was a problem hiding this comment.
Thanks, the wording, the magpie-<name> names, the spec entry and the file mode are all fixed, and same-turn nesting now works. One case is still refused, and it is the main pipeline's normal flow: only the newest skill survives a user prompt, so once the user confirms issue-sync's proposed corrections in a chat reply, issue-fix's own --caller security-issue-fix writes are refused for the rest of the run (see the reply on the nested-skill thread).
This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The maintainer
requesting changes on this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Apache Magpie handles maintainer review:
Contributing guide.
… not use The vetted-ops policy grants operations per caller, but --caller is whatever the agent writes, so a skill whose own caller is refused can rerun the operation under another skill's caller (apache#2124). Add a vetted-ops-caller rule for vetted-op, vetted-op-read, vetted-op-tracker and vetted-op-git launches. Under Claude Code the hook input carries transcript_path; the rule reads the transcript's tail for the latest Skill tool call (or a slash command naming a skill), takes the --caller values written in that skill's own files, and refuses any other caller. A subagent transcript falls back to its parent session's. It allows whenever it cannot tell: no transcript, another harness (Codex writes its own format, so it is not passed one), no skill invoked, or a skill it does not know or that names no caller. The override, MAGPIE_ALLOW_ANY_CALLER=1, is read from the hook's environment only: written inline it would be the agent choosing its own grants. Generated-by: Claude Code (Opus 5.5)
CodeQL flagged the bare `except OSError: pass` in _skill_names. Generated-by: Claude Code (Opus 5.5)
…kill Review of apache#2352. The latest Skill call is not the running skill when one skill runs another and carries on: security-issue-fix runs security-issue-sync first, so its own later writes were refused. - Allow the callers of every skill invoked since the user's last prompt, plus the one running when it was sent (so a skill that asks the user a question keeps its caller). A prompt that is itself a slash command naming a skill starts that skill alone. Tool results and injected messages do not start a turn. - Recognise the magpie-<skills/ link> names that snapshot and self-adoption installs give their skills. - Say in both READMEs and the vetted-command-surface spec that the agent chooses its own Skill calls, so the rule catches an accidental caller swap, not a deliberate one. - test_vetted_caller.py is no longer executable. Generated-by: Claude Code (Opus 5.5)
Second review of apache#2352. issue-fix runs issue-sync, the user confirms issue-sync's corrections in a chat reply, and issue-fix carries on with its own writes; only the newest skill survived that prompt, so --caller security-issue-fix was refused for the rest of the run. Count every skill invoked across the user's last 10 prompts, stopping early at a prompt that is a slash command starting a skill. The rule catches accidental swaps only, so the wider set is a cheaper error than a false refusal in the security pipeline. Generated-by: Claude Code (Opus 5.5)
d69e49f to
23537ce
Compare
Summary
Step 1 of #2124: an agent-guard rule that checks
--calleragainst the skill that is actually running.The vetted-ops policy grants operations per caller, but
--calleris whatever the agent writes, so a skill whose own caller is refused can rerun the operation under another skill's caller. That's what #2124 recorded: the ID-allocation skill writing under--caller security-issue-sync.New bundled rule,
vetted-ops-caller, for everyvetted-op*launch (vetted-op,vetted-op-read,vetted-op-tracker,vetted-op-tracker-batch,vetted-op-tracker-batch-unprompted,vetted-op-git):transcript_path. The rule reads the transcript's tail (at most 32 MiB) for every skill invoked across the user's last 10 prompts, stopping early at a prompt that is a slash command starting a skill. A skill counts if it came from aSkilltool call or a slash command that names it. So a skill that runs another and carries on keeps its own caller, also after the user answers in between (security-issue-fixrunssecurity-issue-sync, the user confirms its corrections, and issue-fix goes on writing). Claude Code repeats each tool call in bookkeeping entries of other types, so onlyassistantentries count. Tool results and injected messages aren't prompts, and built-in commands like/modeldon't start a skill.--caller <name>values written in those skills' own files (plugin skill dir, the bare name orplugin:name, theskills/link name, ormagpie-<link name>as snapshot and self-adoption installs expose it). There's no name guessing. Each shipped skill names exactly one caller, for examplemagpie-security:cve-allocate→security-cve-allocate.On your three open questions, I picked the safe defaults and they're easy to change:
<session>/subagents/agent-*.jsonl) has no skill call, the parent session's transcript is read. That removes the need for a separatesecurity-issue-sync-gatherercaller.issue-sync→security-issue-sync,prepare→release-prepare).Override.
MAGPIE_ALLOW_ANY_CALLER=1is honoured only from the hook's environment, likeMAGPIE_GUARD_OFF. The other guards also accept it inline, but written inline here it would be the agent picking its own grants. Happy to change that if you prefer the usual pattern.Not a boundary. The agent chooses its own
Skillcalls, so the rule catches an accidental caller swap (the #2124 case), not a deliberate one. The per-caller split is still not an authorisation boundary, and both READMEs and the spec say so.Type of change
Test plan
tests/test_vetted_caller.py, 34 tests on synthetic transcripts in Claude Code's line format:--caller=form, bare andplugin:names;Skill(issue-fix)thenSkill(issue-sync), then--caller security-issue-fixis allowed); an outer skill keeps its caller after the user confirms the inner one (Skill(issue-fix),Skill(issue-sync), prompt "yes, apply"); a skill keeps its caller across the user's answers; a skill expires after 10 prompts; everyvetted-op*entry point is checked, including the two batch ones; a tool result doesn't start a turn; an unknown skill in the turn allows; themagpie-<link>name is known; a repeated bookkeeping copy isn't counted; a slash command naming a skill counts,/modeldoesn't;<command-name>isn't an invocation;adversarial-reviewandghcommands;main()denies end to end; Codex isn't passed a transcript;magpie-security:cve-allocate→security-cve-allocate, and the vetted-ops: --caller is self-declared, so per-skill grants are not enforced #2124 case (--caller security-issue-sync) is refused.test_codex.py: thedispatchstub takes the newtranscript_pathargument and asserts Codex passesNone.check-family-plugins.py --fix. The isolated-setup fingerprint was regenerated by its own hook.prek runon the changed files passes.Docs
tools/agent-guard/README.md: avetted-ops-callerrow in the bundled-guards table, plus a note that its override is read from the hook environment only.tools/vetted-ops/README.md: under "The boundary is the entry point, not--caller", what is now checked and what still isn't.tools/spec-loop/specs/vetted-command-surface.md: the rule, its fail-open cases and its hook-env-only override, besidevetted-ops-spelling.Linked issues
Part of #2124 (step 1, the guard).
Was generative AI tooling used to co-author this PR?
I made this with help from Claude Code (Opus 5.5). I checked every line and tested it myself.