Skip to content

fix(agents): clarify empty tool availability prompt - #53000

Closed
zephyn-z wants to merge 2 commits into
openclaw:mainfrom
zephyn-z:fix/empty-tool-list-prompt
Closed

zephyn-z wants to merge 2 commits into
openclaw:mainfrom
zephyn-z:fix/empty-tool-list-prompt

Conversation

@zephyn-z

Copy link
Copy Markdown

Summary

When the filtered tool list is empty, the system prompt currently falls back to a generic full tool list, which can mislead the model into treating unavailable tools as enabled.

This change updates the empty-list path to clearly separate:

  • currently available tools (none), and
  • standard tool catalog (reference only, not enabled for the session).

Behavior for non-empty tool lists is unchanged.

Why

This improves prompt accuracy under strict tool policies (for example, tools.deny: ["*"]) and reduces model confusion caused by fallback wording that implied tools were active.

Changes

  • Updated the empty tool-list branch in src/agents/system-prompt.ts to:
    • explicitly state that no tools are enabled in the current runtime,
    • keep the standard tool list as a reference section only.

Validation

  • Verified prompt generation behavior for empty tool lists.
  • Confirmed non-empty tool-list behavior remains unchanged.

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

greptile-apps Bot commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a misleading system prompt fallback that fired when all tools were denied by policy (e.g. tools.deny: ["*"]). Previously the empty-tool branch rendered "This runtime enables:" followed by the full standard catalog, implying those tools were active. The change replaces this with a two-part structure that first explicitly states no tools are available in the current runtime, then lists the standard catalog as a reference-only section.

  • Core fix is correct: the noEnabledToolsLines constant cleanly separates availability (none) from the informational catalog (reference only), eliminating the model-confusing implication that the listed tools were enabled.
  • Non-empty path unchanged: the ternary preserves identical behavior when toolLines.length > 0.
  • Missing test: system-prompt.test.ts covers other aspects of buildAgentSystemPrompt but has no case for the toolLines.length === 0 branch, which is the exact path this PR modifies. A scoped test would lock in the fix and prevent future regressions.

Confidence Score: 4/5

  • Safe to merge; the fix is correct and tightly scoped to the empty-tool-list branch with no risk to non-empty paths.
  • The logic change is minimal and well-reasoned — it only replaces a misleading string in one branch of a ternary. The non-empty path is completely unaffected. The one non-blocking gap is the absence of a new test for the changed code path, which the repo guidelines explicitly call for on narrowly scoped changes.
  • No files require special attention beyond the missing test noted for src/agents/system-prompt.ts.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/system-prompt.ts
Line: 410-430

Comment:
**No test coverage for empty-tool-list path**

The existing `system-prompt.test.ts` file tests `buildAgentSystemPrompt` (owner sections, etc.) but has no case covering the `toolLines.length === 0` branch — the exact path this PR touches. Per the repo's testing guidelines, narrowly scoped changes should come with a scoped test that directly validates the touched behavior.

Consider adding a case like:

```typescript
{
  name: "no tools (deny all policy)",
  params: {
    workspaceDir: "/tmp/openclaw",
    availableTools: [],
  },
  contains: [
    "- none (tool policy currently disables all tools for this session)",
    "Pi standard tool catalog (reference only; not enabled in this session):",
  ],
  notContains: [
    "This runtime enables:",
  ],
}
```

This makes it straightforward to catch regressions if the empty-tools branch is refactored again in the future.

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

Reviews (1): Last reviewed commit: "fix(agents): clarify empty tool availabi..." | Re-trigger Greptile

Comment on lines +410 to +430
const noEnabledToolsLines = [
"Available tools in this runtime:",
"- none (tool policy currently disables all tools for this session)",
"",
"Pi standard tool catalog (reference only; not enabled in this session):",
"- grep: search file contents for patterns",
"- find: find files by glob pattern",
"- ls: list directory contents",
"- apply_patch: apply multi-file patches",
`- ${execToolName}: run shell commands (supports background via yieldMs/background)`,
`- ${processToolName}: manage background exec sessions`,
"- browser: control OpenClaw's dedicated browser",
"- canvas: present/eval/snapshot the Canvas",
"- nodes: list/describe/notify/camera/screen on paired nodes",
"- cron: manage cron jobs and wake events (use for reminders; when scheduling a reminder, write the systemEvent text as something that will read like a reminder when it fires, and mention that it is a reminder depending on the time gap between setting and firing; include recent context in reminder text if appropriate)",
"- sessions_list: list sessions",
"- sessions_history: fetch session history",
"- sessions_send: send to another session",
"- subagents: list/steer/kill sub-agent runs",
'- session_status: show usage/time/model state and answer "what model are we using?"',
].join("\n");

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 No test coverage for empty-tool-list path

The existing system-prompt.test.ts file tests buildAgentSystemPrompt (owner sections, etc.) but has no case covering the toolLines.length === 0 branch — the exact path this PR touches. Per the repo's testing guidelines, narrowly scoped changes should come with a scoped test that directly validates the touched behavior.

Consider adding a case like:

{
  name: "no tools (deny all policy)",
  params: {
    workspaceDir: "/tmp/openclaw",
    availableTools: [],
  },
  contains: [
    "- none (tool policy currently disables all tools for this session)",
    "Pi standard tool catalog (reference only; not enabled in this session):",
  ],
  notContains: [
    "This runtime enables:",
  ],
}

This makes it straightforward to catch regressions if the empty-tools branch is refactored again in the future.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/system-prompt.ts
Line: 410-430

Comment:
**No test coverage for empty-tool-list path**

The existing `system-prompt.test.ts` file tests `buildAgentSystemPrompt` (owner sections, etc.) but has no case covering the `toolLines.length === 0` branch — the exact path this PR touches. Per the repo's testing guidelines, narrowly scoped changes should come with a scoped test that directly validates the touched behavior.

Consider adding a case like:

```typescript
{
  name: "no tools (deny all policy)",
  params: {
    workspaceDir: "/tmp/openclaw",
    availableTools: [],
  },
  contains: [
    "- none (tool policy currently disables all tools for this session)",
    "Pi standard tool catalog (reference only; not enabled in this session):",
  ],
  notContains: [
    "This runtime enables:",
  ],
}
```

This makes it straightforward to catch regressions if the empty-tools branch is refactored again in the future.

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

@zephyn-z
zephyn-z force-pushed the fix/empty-tool-list-prompt branch from e1479a1 to cd48f39 Compare March 27, 2026 01:53

@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: db2aed625f

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

"- subagents: list/steer/kill sub-agent runs",
'- session_status: show usage/time/model state and answer "what model are we using?"',
].join("\n"),
toolLines.length > 0 ? toolLines.join("\n") : noEnabledToolsLines,

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 Gate wait-loop tool guidance on enabled tools

When toolLines.length === 0, the prompt now correctly says no tools are enabled, but the surrounding tooling section still gives imperative guidance to use exec/process for long waits. In sessions with strict deny-all tool policy, this leaves contradictory instructions in the same prompt and can still drive the model to call unavailable tools, undermining the empty-tool fix. Consider suppressing or rewriting that guidance when no tools are available.

Useful? React with 👍 / 👎.

@zephyn-z
zephyn-z force-pushed the fix/empty-tool-list-prompt branch from db2aed6 to 9f82a78 Compare March 30, 2026 02:33
@zephyn-z
zephyn-z force-pushed the fix/empty-tool-list-prompt branch from 9f82a78 to 05577e7 Compare March 30, 2026 02:54
@openclaw-barnacle openclaw-barnacle Bot added the channel: telegram Channel integration: telegram label Mar 30, 2026

@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: 05577e77a8

ℹ️ 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 on lines +409 to +413
"Available tools in this runtime:",
"- none (tool policy currently disables all tools for this session)",
"",
"Pi standard tool catalog (reference only; not enabled in this session):",
"- grep: search file contents for patterns",

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 Gate subagent/session guidance when no tools are enabled

When toolNames is empty (for example under a deny-all tool policy), this block now explicitly says no tools are enabled, but the same prompt still unconditionally instructs the model to spawn sub-agents and references subagents/sessions_list usage later in the section. In that runtime these tools are unavailable, so the prompt becomes self-contradictory and can drive invalid tool calls; the subagent/session guidance should be omitted or rewritten when those tools are not enabled.

Useful? React with 👍 / 👎.

@zephyn-z
zephyn-z force-pushed the fix/empty-tool-list-prompt branch from 05577e7 to a8f8f98 Compare March 30, 2026 03:03
@openclaw-barnacle openclaw-barnacle Bot removed the channel: telegram Channel integration: telegram label Mar 30, 2026

@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: a8f8f98c96

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

"- subagents: list/steer/kill sub-agent runs",
'- session_status: show usage/time/model state and answer "what model are we using?"',
].join("\n"),
toolLines.length > 0 ? toolLines.join("\n") : noEnabledToolsLines,

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 Gate session_status advice when no tools are enabled

With toolNames filtered to empty (for example under a deny-all tool policy), this new branch now explicitly says no tools are enabled, but the prompt can still include If you need the current date, time, or day of week, run session_status when userTimezone is present. That contradiction can drive guaranteed-invalid tool calls in no-tool sessions and degrade reliability; this guidance should be conditioned on session_status actually being enabled (or suppressed in the no-tools path).

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web labels Mar 30, 2026
@zephyn-z
zephyn-z force-pushed the fix/empty-tool-list-prompt branch from 784eef3 to 220554b Compare March 30, 2026 03:35
@openclaw-barnacle openclaw-barnacle Bot removed the channel: discord Channel integration: discord label Mar 30, 2026

@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: 220554bda1

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

"- subagents: list/steer/kill sub-agent runs",
'- session_status: show usage/time/model state and answer "what model are we using?"',
].join("\n"),
toolLines.length > 0 ? toolLines.join("\n") : noEnabledToolsLines,

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 Gate tool-call directive when no tools are enabled

In the empty-tool path (toolLines.length === 0), this section now explicitly says no tools are enabled, but it still keeps the global instruction to "Call tools exactly as listed" immediately before rendering a reference catalog that includes disabled tools like exec and subagents. In deny-all sessions this creates conflicting guidance and can drive guaranteed-invalid tool calls, so the directive should be conditioned on enabled tools (or rewritten for the no-tool branch).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant