Repository navigation
fix(mod): open a subagent card only once Claude Code allowed the Agent call - #75
Merged
Merged
Conversation
…t call The agent-cards mod answered the Agent tool.call before calling next, which is where Claude Code applies its permission rules, mode, dialog and PreToolUse hooks. A deny or ask rule never applied, and a call the user rejected could still open a lich session that ran the task. The mod now passes a call it takes on beneath it and opens the worker at agent.spawn, which Claude Code raises only once the call was allowed and before the native agent or its worktree exist; it denies that spawn and answers the Agent call with lich's outcome. Both orders measured on 2.1.296. Fixes #74
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.
Fixes #74.
Cause
hooks/agent-cards.jsanswered the Agenttool.callwithout callingnext. In Claude Code,nextis where the permission flow lives: rules, mode, the dialog and PreToolUse hooks. So none of them ever applied to a call the mod took. Measured on 2.1.296: withpermissions.ask: ["Agent"], the old mod opened the lich session and no dialog appeared at all.Fix
The mod still decides in
tool.callwhether it takes the call, but it now passes the call on tonext. It opens the worker atagent.spawn, which Claude Code raises only once the call was allowed and before the native agent or its worktree exist. There it denies the native spawn and answers the Agent call with lich's outcome. A call refused at the permission check never reachesagent.spawn, so lich opens nothing. The fallback to the native agent before lich has the task, and the deny on Esc, behave as before.Verification
node --test tests/*.test.mjs: 417/417. The two new tests inagent-cards.test.mjs(a refused call opens nothing; a refusal does not affect the next allowed call) fail against the old mod.claude plugin test .: 32/32.--plugin-dir, a fakeLICH_BINand anaskrule on Agent:lichwas never called.lich open --worktree subagent/...ran, the call came back as a backgrounded agent, and no native worktree was left over.Test changes
agent-cards.test.mjsandprompt-text.test.mjsnow model what was measured: beneath an Agent call'snext, the permission decision comes first, thenagent.spawn, then the native agent. The existing assertions are unchanged.agent-cards.engine.test.tspinned the open happening abovenext. The kit refuses$.agent.spawnfrom a test's hook, so it cannot express the new chain. They now assert what it can: a taken call reaches the permission check, and a refusal there runs no lich. The open path is covered by the unit suite and the live run.