Repository navigation
refactor(tools): enforce disallowed_tools only through the rule layer - #8747
CodeGhost21 wants to merge 1 commit into
Conversation
`disallowed_tools` already becomes a deny rule (`agent_rule_layer`) that the harness tool gate applies to the catalogue, `tool_search` and every call, on session turns (`session_rule_set`), sub-agent turns (`child_rule_policy`) and hosted runs (the projected definition's `tool_rules`). Drop the duplicate `glob_list_matches` re-filters in the session builder, sub-agent tool preparation and the hosted definition projection, and delete the wrapper. The agent-library listing keeps its own filter (an RPC display the rule gate never sees), now on `tinytools::glob_matches` directly. Regression tests drive a real harness turn with no allowlist and check that a disallowed tool, exact or globbed, direct or deferred, is refused by name and never surfaced by `tool_search`, for both session and sub-agent rules, plus a typed-mode sub-agent run that calls a disallowed tool by name. Refs senamakel#364 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6aa6a51ced
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // "no filter", so it needs nothing. An agent that disallows it still | ||
| // loses it: `disallowed_tools` is a deny rule in the session's rule | ||
| // set (`tools::rules::agent_rule_layer`), which the prompt catalogue, | ||
| // the harness catalogue, `tool_search` and every call obey. |
There was a problem hiding this comment.
Keep wildcard belts empty before builder expansion
With a custom ToolScope::Wildcard definition that has a nonempty denylist and a { skills = "*" } entry yielding deferred Composio tools, removing the Wildcard branch leaves visible containing only delegation_tools (lines 316–322). SessionHostBuilder::build then sees a nonempty set and sets belt_is_wildcard false (builder_build.rs:128), so it never expands the durable registry: all ordinary allowed tools and tool_search disappear, rather than just the names denied by the rule. Keep the wildcard represented as empty through this path, or materialize the full allowed set before applying the rule.
Useful? React with 👍 / 👎.
Summary
disallowed_toolsis now enforced only through the harnessToolRuleSetdeny rule (agent_rule_layer). Before, the same list was also re-filtered byglob_list_matchesat five session, sub-agent and definition call sites.glob_list_matcheswrapper. The agent-library RPC listing keeps its filter, because the rule gate never sees it.tool_search, and never executed, for both sessions and sub-agents.Problem
Tool visibility was decided twice for the same list. That's two places to keep in sync, and the hand filters only removed tools from the session's tool list. A guessed name or
tool_searchrelied on the rule layer anyway.Solution
session_host/builder/factory/build_session.rs(Wildcard and Named)scope_defkeepsdisallowed_tools. Each turn installssession_rule_set(ensure.rs→turn_tool_rules→turn_run_policy→install_turn_rules), and the system prompt drops those tools (rule_withheld_tools).subagent_host/tool_prep.rs(first pass, the recovery-tool exception, andextra_tools)for_subagent(definition)→child_rule_policyaddsagent_rule_layer, which reachesrun_subagent_via_graph→TurnSpec.rule_listed_indiceskeeps denied tools off the child's prompt.tinyagents/host/definition_registry.rs(Named and Wildcard)project()setstool_rules: agent_rule_layer(def), and the harness applies it inToolGate::new. Hosted children inherit it throughinherited_rules.agent_registry/library/ops.rstinytools::glob_matchesdirectly.The issue's
ops/runner.rsandspawn_parallel/staging.rscall sites no longer exist on main.Glob semantics are identical.
glob_list_matcheswaspatterns.iter().any(|p| tinytools::glob_matches(p, name)).ToolRule::names(Deny, …)matches throughPatterns::matches, which is the sameglob_matches(*/?, ASCII case-insensitive). With an emptyonlist it applies on every surface.Behaviour changes: decision needed
repeated_failure/ClassifiedFailureTrackerclassifies aspermission. The sub-agent halts after one attempt ("Stopping after 1 attempt(s): failure classpermission…") and endsIncomplete. Root sessions very likely behave the same, since they use the same middleware.[tool_rules]deny already does today. Models do guess tool names, though, so runs that used to recover can now end early.[tool_rules]denies.disallowed_toolsnow gets the normal wildcard tool list. The old Wildcard branch turned the list into "all tools minus denied", which disabledtool_search, listed Deferred tools directly and kept Hiddentodo_*tools visible. Nowtool_searchis on and Deferred and Hidden tools are stripped. Only custom agents withtool_allowlist = ["*"]plus a denylist are affected; every built-in agent has a Named scope.Submission Checklist
tools/rules/ops_tests.rsruns a realAgentHarnesswith rules installed:a_session_refuses_disallowed_tools_by_name_and_in_tool_search,a_sub_agent_refuses_its_disallowed_tools_by_name_and_in_tool_searchanda_sub_agent_refuses_its_own_disallowed_tools_under_a_restricted_parent. They cover exact names and globs, direct and deferred tools, and check that an allowed tool still runs.typed_mode_refuses_disallowed_tools_called_by_nameis an end-to-end typed-mode run.Impact
disallowed_tools; the change is a no-op for an empty list.Related
user_filteras a user rule layer;DomainGrouptags instead ofops_tool_groups;openhuman debugprompt dump now lists disallowed tools, since it already ignored[tool_rules];running_subagents_tests.rsandspawn_parallel/staging_tests.rs.AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
chore/364-disallowed-tools-rule6aa6a51cedValidation Run
pnpm --filter openhuman-app format:check: N/Apnpm typecheck: N/Atyped_mode_,tool_prep,tools::rules::,definition_registryandagent_registry::librarypass 85/85. A wider run ofagent::session_host::andagent::subagent_host:::typed_transcript_compat×2,a_detached_driver_uses_its_carried_actor_for_lifecycle_commits,resolve_subagent_source_hint_with_config_routes_via_factory) were rerun onorigin/maindbbaf7f8dband fail identically there.cargo test --no-runpasses with product features, and gates-off passes with--lib --tests.Validation Blocked
command:check-test-ownership,check-security-module-dependencieserror:test-ownership flags three files this PR doesn't touch; security-module-deps can't run without localnode_modulesimpact:none from this branchBehavior Changes
disallowed_tools; see the decision aboveParity Contract
tool_searchand catalogue are all covered by the new testsDuplicate / Superseded PR Handling
🤖 Generated with Claude Code
Summary by CodeRabbit