Add per-call tool gate hook#377
Merged
JackChen-me merged 2 commits intoJul 16, 2026
Merged
Conversation
Member
|
Core approach looks right, but I hit four edge cases locally: aborting while the async gate is pending still executes the tool, malformed decisions can reject |
Contributor
Author
|
Pushed
Added regression coverage for each path. Local validation run:
The branch is updated and GitHub checks should rerun on the new head. |
This was referenced Jul 16, 2026
JackChen-me
added a commit
that referenced
this pull request
Jul 16, 2026
…rs subpath (#382) Ships an opt-in, dependency-free shell risk classifier for the onToolCall gate (#377). classifyBashCommand(command) returns safe | review | high so users get the taxonomy from #96 without writing regex tables by hand. - safe: read-only inspection (ls, cat, grep/rg with a path, git status/log/diff) - review: context bombs and unknowns (ls -R, find / without -maxdepth, grep -r / rg -r without scope, tree, du, unrecognised commands) - high: destructive/sensitive (rm, sudo, curl | bash, dd, mkfs, chmod 777/-R, git push --force, npm publish) Compound commands are segmented on shell separators and the highest risk wins; quoted strings are stripped so patterns inside a string do not match. Convenience heuristic, not a security boundary. Exported only via @open-multi-agent/core/classifiers so pattern tables never load unless imported. Closes #379
JackChen-me
added a commit
that referenced
this pull request
Jul 16, 2026
…example Third split of #96 (follow-up to #379). The onToolCall gate shipped in #377 and the classifyBashCommand classifier in #379; this documents both and adds a runnable example. - docs/tool-configuration.md: a "Per-call gating with onToolCall" section (where it sits, ToolCallContext/ToolCallDecision, deny returns an error ToolResult not a throw, agent overrides orchestrator default, orthogonal to onApproval, gated/gateAction/gateReason on the trace with gateReason redacted, not a security boundary) plus a shell risk classifier subsection. - examples/patterns/risk-gated-bash.ts: a security-audit agent that classifies each bash command and routes safe/review/high to allow/human-approval/deny. - AGENTS.md: cross-links in the tool-layer notes + /classifiers in the exports map. Closes #380
JackChen-me
added a commit
that referenced
this pull request
Jul 16, 2026
…example Third split of #96 (follow-up to #379). The onToolCall gate shipped in #377 and the classifyBashCommand classifier in #379; this documents both and adds a runnable example. - docs/tool-configuration.md: a "Per-call gating with onToolCall" section (where it sits, ToolCallContext/ToolCallDecision, deny returns an error ToolResult not a throw, agent overrides orchestrator default, orthogonal to onApproval, gated/gateAction/gateReason on the trace with gateReason redacted, not a security boundary) plus a shell risk classifier subsection. - examples/patterns/risk-gated-bash.ts: a security-audit agent that classifies each bash command and routes safe/review/high to allow/human-approval/deny. - AGENTS.md: cross-links in the tool-layer notes + /classifiers in the exports map. Closes #380
JackChen-me
added a commit
that referenced
this pull request
Jul 16, 2026
…example (#383) Third split of #96 (follow-up to #379). The onToolCall gate shipped in #377 and the classifyBashCommand classifier in #379; this documents both and adds a runnable example. - docs/tool-configuration.md: a "Per-call gating with onToolCall" section (where it sits, ToolCallContext/ToolCallDecision, deny returns an error ToolResult not a throw, agent overrides orchestrator default, orthogonal to onApproval, gated/gateAction/gateReason on the trace with gateReason redacted, not a security boundary) plus a shell risk classifier subsection. - examples/patterns/risk-gated-bash.ts: a security-audit agent that classifies each bash command and routes safe/review/high to allow/human-approval/deny. - AGENTS.md: cross-links in the tool-layer notes + /classifiers in the exports map. Closes #380
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.
What
Adds an optional per-call
onToolCallgate for tool execution. The hook runs after tool input validation and before the tool implementation, and can returnallowordenyfor that specific call.Denied calls return a normal error
ToolResultwithout invoking the tool, and trace events include compact gate metadata when a gate evaluates a tool call.Why
Part of #96.
This gives applications a policy hook for risk decisions around built-in shell/filesystem tools without changing the existing default-deny, allowlist, denylist, or tool preset behavior.
Validation
npm run lintnpm testnpm run buildnpm run test:coveragenpm run test:scaffoldChecklist
npm run lintpassesnpm testpassesDisclosure: I used AI-assisted coding tools while preparing this PR. I reviewed the changes myself, tested them, and take responsibility for the implementation and any follow-up revisions needed.