Skip to content

fix(agents): clarify unavailable core tool warnings - #38849

Closed
dafacto wants to merge 2 commits into
openclaw:mainfrom
dafacto:codex/fix-tool-policy-warning
Closed

dafacto wants to merge 2 commits into
openclaw:mainfrom
dafacto:codex/fix-tool-policy-warning

Conversation

@dafacto

@dafacto dafacto commented Mar 7, 2026

Copy link
Copy Markdown

Summary

Improve tool-policy warnings so known core tools that are missing from the active runtime toolset are not reported as unknown entries.

Previously, tools.profile (coding) could log warnings like:

  • allowlist contains unknown entries (apply_patch, cron)

That was misleading when apply_patch and cron were valid built-in tools in the coding profile but unavailable in the specific runtime context for a turn.

What changed

  • teach stripPluginOnlyAllowlist() to distinguish:
    • truly unknown allowlist entries
    • known core tool ids that are unavailable in the current runtime context
  • keep existing filtering behavior intact
  • emit a clearer warning for the second case:
    • allowlist includes known tools unavailable in this runtime context (...)

Why

This warning sends operators toward the wrong root cause. The config and built-in profile can be correct even when the per-turn active toolset omits some tools.

Testing

  • corepack pnpm exec vitest run src/agents/tool-policy.plugin-only-allowlist.test.ts src/agents/tool-policy-pipeline.test.ts
  • corepack pnpm exec tsc -p tsconfig.json --noEmit --pretty false (fails in this checkout due unrelated missing extension deps: @pierre/diffs, @tloncorp/api)

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Mar 7, 2026
@greptile-apps

greptile-apps Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves the operator-facing warning when a tool allowlist references core tools that are valid in the built-in profile but not available in the active per-turn runtime, preventing misleading "unknown entries" messages for tools like apply_patch and cron. The change is well-scoped: it adds an unavailableCoreAllowlist bucket to AllowlistResolution, populates it in stripPluginOnlyAllowlist using the new isKnownCoreToolId lookup, and emits a distinct, clearer warning from the pipeline.

Key changes:

  • AllowlistResolution gains a new unavailableCoreAllowlist: string[] field to separate "known but currently unavailable" from "truly unknown" entries.
  • stripPluginOnlyAllowlist uses isKnownCoreToolId (from tool-catalog) to route entries into the new bucket rather than unknownAllowlist.
  • applyToolPolicyPipeline emits the new warning before the existing unknown-entries warning.
  • Tests cover the new path both at the unit level (tool-policy.plugin-only-allowlist.test.ts) and at the pipeline level (tool-policy-pipeline.test.ts).

Issue found:

  • When an allowlist consists entirely of unavailable core tools (no active core tool, no unknown entries), strippedAllowlist becomes true and the allowlist is silently stripped. The new warning doesn't include the "Ignoring allowlist so core tools remain available" suffix that the previous code path (via unknownAllowlist) would have emitted, leaving operators without a diagnostic that their full allowlist was discarded.

Confidence Score: 4/5

  • This PR is safe to merge; it only changes warning messages and adds a new diagnostic field without affecting tool filtering behavior.
  • The core logic is sound and existing filtering is unchanged. The one gap — the "allowlist stripped" notice not being emitted when only unavailable core tools are present — is a minor diagnostic regression limited to an edge-case configuration, not a functional bug.
  • src/agents/tool-policy-pipeline.ts — the unavailableCoreAllowlist warning block should also surface strippedAllowlist when applicable.

Last reviewed commit: 6314510

Comment on lines +92 to +97
if (resolved.unavailableCoreAllowlist.length > 0) {
const entries = resolved.unavailableCoreAllowlist.join(", ");
params.warn(
`tools: ${step.label} allowlist includes known tools unavailable in this runtime context (${entries}).`,
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stripping not surfaced when allowlist contains only unavailable core tools

When the entire allowlist consists of known-but-unavailable core tools (e.g. allow: ["apply_patch", "cron"] with no active core tool present in the runtime), two things happen simultaneously:

  1. unavailableCoreAllowlist is populated → the new warning is emitted.
  2. hasCoreEntry stays false → strippedAllowlist = true → policy.allow is set to undefined.

However, because unknownAllowlist is empty in this case, the second if block is never reached and its "Ignoring allowlist so core tools remain available. Use tools.alsoAllow for additive plugin tool enablement." suffix is never printed.

Before this PR, those same entries fell into unknownAllowlist, so the existing warning already mentioned the stripping. After the PR, an operator whose allowlist contains only unavailable core tools now gets a warning about the unavailable tools but no indication that the whole allowlist has been silently dropped.

Consider checking resolved.strippedAllowlist inside the new block and appending the stripping notice when applicable:

Suggested change
if (resolved.unavailableCoreAllowlist.length > 0) {
const entries = resolved.unavailableCoreAllowlist.join(", ");
params.warn(
`tools: ${step.label} allowlist includes known tools unavailable in this runtime context (${entries}).`,
);
}
if (resolved.unavailableCoreAllowlist.length > 0) {
const entries = resolved.unavailableCoreAllowlist.join(", ");
const suffix = resolved.strippedAllowlist
? " Ignoring allowlist so core tools remain available. Use tools.alsoAllow for additive plugin tool enablement."
: "";
params.warn(
`tools: ${step.label} allowlist includes known tools unavailable in this runtime context (${entries}).${suffix}`,
);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/tool-policy-pipeline.ts
Line: 92-97

Comment:
**Stripping not surfaced when allowlist contains only unavailable core tools**

When the entire allowlist consists of known-but-unavailable core tools (e.g. `allow: ["apply_patch", "cron"]` with no active core tool present in the runtime), two things happen simultaneously:

1. `unavailableCoreAllowlist` is populated → the new warning is emitted.
2. `hasCoreEntry` stays `false` → `strippedAllowlist = true` → `policy.allow` is set to `undefined`.

However, because `unknownAllowlist` is empty in this case, the second `if` block is never reached and its "Ignoring allowlist so core tools remain available. Use `tools.alsoAllow` for additive plugin tool enablement." suffix is never printed.

Before this PR, those same entries fell into `unknownAllowlist`, so the existing warning already mentioned the stripping. After the PR, an operator whose allowlist contains **only** unavailable core tools now gets a warning about the unavailable tools but no indication that the whole allowlist has been silently dropped.

Consider checking `resolved.strippedAllowlist` inside the new block and appending the stripping notice when applicable:

```suggestion
      if (resolved.unavailableCoreAllowlist.length > 0) {
        const entries = resolved.unavailableCoreAllowlist.join(", ");
        const suffix = resolved.strippedAllowlist
          ? " Ignoring allowlist so core tools remain available. Use tools.alsoAllow for additive plugin tool enablement."
          : "";
        params.warn(
          `tools: ${step.label} allowlist includes known tools unavailable in this runtime context (${entries}).${suffix}`,
        );
      }
```

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6314510803

ℹ️ 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".

Comment thread src/agents/tool-policy.ts
Comment on lines +183 to +185
if (!isCoreEntry && isKnownCoreEntry) {
unavailableCoreAllowlist.push(entry);
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve plugin matches before marking entries unavailable

If an allowlist entry is both a plugin tool and a known core id (for example, a plugin exposes apply_patch while the built-in apply_patch is unavailable in this runtime), this branch classifies it as unavailableCoreAllowlist and exits early even though isPluginEntry is true. That produces a misleading runtime warning and hides the plugin/unknown-entry guidance for that item, which can send operators toward the wrong fix path in mixed core+plugin deployments.

Useful? React with 👍 / 👎.

@dafacto

dafacto commented Mar 7, 2026

Copy link
Copy Markdown
Author

Addressed the diagnostic gap Greptile called out.

What changed:

  • preserved the existing "Ignoring allowlist so core tools remain available" context when the allowlist contains only known core tools that are unavailable in the active runtime
  • added a regression test for the unavailable-core-only case

Validation:

  • corepack pnpm exec vitest run src/agents/tool-policy.plugin-only-allowlist.test.ts src/agents/tool-policy-pipeline.test.ts

The update is in ff4f47e3d.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 22, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing this as implemented after Codex review.

Current main already addresses the misleading unavailable-core-tool warning path, so this PR is redundant.

What I checked:

  • Default profile steps suppress baseline unavailable-core warnings: buildDefaultToolPolicyPipelineSteps() carries profileUnavailableCoreWarningAllowlist / providerProfileUnavailableCoreWarningAllowlist, and applyToolPolicyPipeline() filters those entries out before warning. (src/agents/tool-policy-pipeline.ts:39, 84fc00afdacb)
  • Regression tests cover the original tools.profile (coding) case: Tests assert no warning for tools.profile (coding) when apply_patch is unavailable, and no warning for default coding profile steps built from resolveToolProfilePolicy("coding"). (src/agents/tool-policy-pipeline.test.ts:79, 84fc00afdacb)
  • Runtime tool resolution uses the suppression path on main: pi-tools passes profilePolicy?.allow and providerProfilePolicy?.allow into buildDefaultToolPolicyPipelineSteps(), so live tool selection uses the new unavailable-core suppression behavior. (src/agents/pi-tools.ts:671, 84fc00afdacb)
  • Explicit custom allowlists now get clarified unavailable-core messaging: Main still warns for an explicit tools.allow: ["apply_patch"], but the test requires the warning text to explain that the entry is a shipped core tool unavailable in the current runtime/provider/model/config. (src/agents/tool-policy-pipeline.test.ts:102, 84fc00afdacb)

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against 84fc00afdacb; fix evidence: commit 84fc00afdacb.

@steipete steipete closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants