You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
weft does not log what it blocks, and MCP tool calls bypass the guards #2
Two gaps found while building the crew loop in dioptx/agentry.
Nothing records a refusal. A guard that denies a command leaves no trace anywhere, so a builder that was stopped and a builder that never tried look the same afterwards. The agentry events stream (~/.local/state/agentry/events.jsonl) is the place: one guard line per refusal, carrying the tool, the refused input, the rule that fired, and build_id/task from the AGENT_P_TAGS environment, which the loop already sets.
A shell command inside an MCP call is invisible. Guards match Bash, Edit, Write. A tool such as context-mode's ctx_execute takes a shell command as an MCP input and runs it; measured on 2026-09-12, with that plugin's hooks installed Bash never fired once and every command became an MCP call. Any guard that matters must match mcp__* inputs carrying a command the same way it matches Bash.
Spec attempt guard-events was killed by a subscription limit before it ran.
A concrete shape for the two gaps, in case it is useful for the crew loop.
Refusal logging. Put the record in the same events.jsonl stream the loop already reads, one line per refusal, and give it a fixed schema so the loop can assert on it without parsing prose:
Store a hash plus a redacted preview, not the raw input. The refused command is often the thing you least want copied into a shared log file, but a preview is what makes the event useful when you are debugging why something got blocked.
Record the allow path too. A line per refusal only tells you what stopped; a matching outcome: "allowed" line lets you compute the ratio and tells you a rule is mis-calibrated, which is otherwise invisible.
MCP-embedded shell. Guards that match on tool name will always miss a shell command that arrives as an argument. The robust place to close it is the dispatch boundary rather than the tool list: wrap the actual tool invocation, and before dispatch inspect the argument payload for shell-bearing keys (command, cmd, script, shell, or any string that matches a shell metacharacter heuristic). If one is found, route it through the same guard as Bash instead of calling the tool.
This is the same shape as a proxy - one interception point, every tool covered - rather than a per-tool allowlist you have to keep in sync as new MCP servers appear.
One caveat from the other side of that: intercepting on a metacharacter heuristic will produce false positives on legitimate tools that take free-form text (a search query with an && in it, for example). Worth logging the classification decision either way, so the noise is auditable.
Coming at this from the recording side: I maintain Agentmetry, an open-source recorder for coding agents, and your second point here is a gap in mine too. A credential read piped to curl is classified when an MCP tool passes it as a top-level command, and missed in seven other shapes your guard engine now handles, including context-mode's code and commands inputs. Filed with weft credited as prior art: blitzcrieg1/agentmetry#433
Would you be OK with me porting the extraction rules from core/guard_engine.py, with credit, and reusing your edge cases as test cases?
One thing back that may matter for the Stop gate: Claude Code does not run Stop when a turn is interrupted, so the gate never sees that turn end. StopFailure and SessionEnd cover the error and exit cases.
Activity
Ally-sudi commentedon Oct 19, 2026
Nice
surlymochan commentedon Oct 20, 2026
A concrete shape for the two gaps, in case it is useful for the crew loop.
Refusal logging. Put the record in the same
events.jsonlstream the loop already reads, one line per refusal, and give it a fixed schema so the loop can assert on it without parsing prose:{"ts":"...","type":"guard","outcome":"refused","tool":"Bash","rule":"no-rm-force","input_sha256":"...","input_preview":"...","build_id":"...","task":"..."}Two details worth deciding up front:
outcome: "allowed"line lets you compute the ratio and tells you a rule is mis-calibrated, which is otherwise invisible.MCP-embedded shell. Guards that match on tool name will always miss a shell command that arrives as an argument. The robust place to close it is the dispatch boundary rather than the tool list: wrap the actual tool invocation, and before dispatch inspect the argument payload for shell-bearing keys (
command,cmd,script,shell, or any string that matches a shell metacharacter heuristic). If one is found, route it through the same guard asBashinstead of calling the tool.This is the same shape as a proxy - one interception point, every tool covered - rather than a per-tool allowlist you have to keep in sync as new MCP servers appear.
One caveat from the other side of that: intercepting on a metacharacter heuristic will produce false positives on legitimate tools that take free-form text (a search query with an
&&in it, for example). Worth logging the classification decision either way, so the noise is auditable.Guards: check commands inside MCP tool inputs (#2) (#9)
blitzcrieg1 commentedon Nov 15, 2026
Coming at this from the recording side: I maintain Agentmetry, an open-source recorder for coding agents, and your second point here is a gap in mine too. A credential read piped to
curlis classified when an MCP tool passes it as a top-levelcommand, and missed in seven other shapes your guard engine now handles, including context-mode'scodeandcommandsinputs. Filed with weft credited as prior art: blitzcrieg1/agentmetry#433Would you be OK with me porting the extraction rules from
core/guard_engine.py, with credit, and reusing your edge cases as test cases?One thing back that may matter for the Stop gate: Claude Code does not run Stop when a turn is interrupted, so the gate never sees that turn end. StopFailure and SessionEnd cover the error and exit cases.
dioptx commentedon Nov 17, 2026
Both gaps are fixed on main, so I am closing this.
Evidence: the full Weft suite passes on main at f55e755 (2992 passed, 2026-11-17).
The local branch amp/mcp-guards (5a10bae) is an earlier attempt at the MCP half. #9 replaced it, so it is not merged.