Skip to content

fix(agents): remove unconditional "Tools are disabled" prompt injection in CLI runner - #46214

Merged
steipete merged 3 commits into
openclaw:mainfrom
Dhi13man:fix/cli-runner-tools-disabled-injection
Mar 26, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
Dhi13man:fix/cli-runner-tools-disabled-injection

Conversation

@Dhi13man

Copy link
Copy Markdown
Contributor

Summary

  • Remove hardcoded "Tools are disabled in this session. Do not call tools." text that runCliAgent() unconditionally appended to every CLI backend session's extraSystemPrompt
  • Add regression test verifying the injected text is absent from CLI arguments

Problem

runCliAgent() in src/agents/cli-runner.ts builds extraSystemPrompt as:

const extraSystemPrompt = [
  params.extraSystemPrompt?.trim(),
  "Tools are disabled in this session. Do not call tools.",
].filter(Boolean).join("\n");

This text was intended to prevent the LLM from calling OpenClaw's embedded API tools (since CLI backends manage their own tools natively, and tools: [] is already passed). However, CLI agents like Claude Code interpret the injected text as a blanket prohibition on all tools, including their own native Bash, Read, Write, etc.

Impact: Silent failures across cron jobs, group chats, and DM sessions when using any CLI backend. The agent sees "Tools are disabled" in the system prompt and refuses to execute tools, returning text-only responses. Cron jobs report lastStatus: "ok" despite failing to run scripts.

Root cause analysis

Traced via reverse engineering the minified dist bundles (v2026.3.8 and v2026.3.13):

  • disableTools param is not set to true for group/cron sessions anywhere in the codebase
  • The only disableTools: true is in llm-task-tool.ts (LLM-only sub-agents)
  • Group chat tool restriction uses a separate GroupToolPolicy mechanism
  • The problem is purely this prompt text injection in runCliAgent()
  • The injected text is redundant: CLI backends already receive tools: [] in buildSystemPrompt(), so the LLM has no OpenClaw tools to call regardless

Fix

// Before:
const extraSystemPrompt = [
  params.extraSystemPrompt?.trim(),
  "Tools are disabled in this session. Do not call tools.",
].filter(Boolean).join("\n");

// After:
const extraSystemPrompt = params.extraSystemPrompt?.trim() ?? "";

Test plan

  • Added regression test: "does not inject hardcoded 'Tools are disabled' text into CLI arguments"
  • Existing cli-runner.test.ts tests pass (CI)
  • pnpm check passes (CI)

AI disclosure

This PR was authored with AI assistance (Claude Code). The root cause was identified by reverse engineering the minified dist bundles, confirmed against the TypeScript source, and validated against real-world cron session transcripts showing the failure. The fix and test follow existing patterns in cli-runner.test.ts.

Closes #44135

Generated with Dhiman's Agentic Suite

…on in CLI runner

`runCliAgent()` unconditionally appended "Tools are disabled in this
session. Do not call tools." to `extraSystemPrompt` for every CLI
backend session. The intent was to prevent the LLM from calling
OpenClaw's embedded API tools (since CLI backends manage their own
tools natively). However, CLI agents like Claude Code interpret this
text as a blanket prohibition on ALL tools, including their own native
Bash, Read, and Write tools.

This caused silent failures across cron jobs, group chats, and DM
sessions when using any CLI backend: the agent would see the injected
text in the system prompt and refuse to execute tools, returning text
responses instead. Cron jobs reported `lastStatus: "ok"` despite the
agent failing to run scripts.

The fix removes the hardcoded string entirely. CLI backends already
receive `tools: []` (no OpenClaw embedded tools in the API call), so
the text was redundant at best.

Closes #44135

Co-Authored-By: Dhiman's Agentic Suite <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Mar 14, 2026
@greptile-apps

greptile-apps Bot commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes a hardcoded "Tools are disabled in this session. Do not call tools." string that was unconditionally appended to extraSystemPrompt for every CLI backend session in runCliAgent(). Because CLI backends like Claude Code have their own native toolset (Bash, Read, Write, etc.), the injected text caused them to refuse all tool use, silently breaking cron jobs, group chats, and DMs. The fix is safe: tools: [] is already passed via buildSystemPrompt(), so OpenClaw's embedded API tools remain unavailable to CLI backends regardless of the removed text. A regression test is included that verifies the banned string no longer appears in the argv forwarded to the process supervisor.

Key changes:

  • src/agents/cli-runner.ts: Replaces the multi-element array join with params.extraSystemPrompt?.trim() ?? "" — a minimal, correct change.
  • src/agents/cli-runner.test.ts: Adds a regression test asserting the injected string is absent from the CLI arguments, following the established patterns in the test file.

Confidence Score: 5/5

  • This PR is safe to merge — it removes a harmful, redundant prompt injection and includes a focused regression test.
  • The fix is minimal (one line changed), correct (the removed text was redundant because tools: [] already prevents OpenClaw API tool use), and accompanied by a regression test. The root cause analysis in the PR description is thorough, and the new behavior matches the intended design for CLI backends.
  • No files require special attention.

Last reviewed commit: 4f34200

@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: 4f342009bc

ℹ️ 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/cli-runner.test.ts Resolved
Previous run had a flaky Telegram extension test failure (429 rate
limit in extensions/telegram/src/send.test.ts) unrelated to this
change.

Co-Authored-By: Dhiman's Agentic Suite <[email protected]>
@Dhi13man

Copy link
Copy Markdown
Contributor Author

CI note: The checks (node, extensions, pnpm test:extensions) failure is unrelated to this change. It fails with Telegram 429 rate limits and Signal/Slack monitor test errors in the extensions test suite. The same check fails on the last 4 merged PRs (#46247, #46061, #45969, #45967).

All checks relevant to the changed files pass:

  • check (type checking): pass
  • checks (node, test, 1/2) and checks (node, test, 2/2) (unit tests including cli-runner.test.ts): pass
  • All 6 checks-windows shards: pass
  • checks (bun, test): pass
  • checks (node, protocol): pass
  • Greptile Review: pass
  • actionlint, no-tabs, secrets, install-smoke: pass

codex-cli lacks systemPromptArg, so the system prompt is never
serialized into argv — making the not-toContain assertion pass
vacuously even on pre-fix code. Switch to claude-cli which defines
systemPromptArg ("--append-system-prompt") and add a positive
assertion that the user-supplied prompt IS present in argv.

Co-Authored-By: Dhiman's Agentic Suite <[email protected]>

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

ℹ️ 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/cli-runner.ts Resolved
@steipete
steipete merged commit 9f8c4ef into openclaw:main Mar 26, 2026
31 of 33 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm test -- src/agents/cli-runner.test.ts; full repo check currently fails on unrelated fresh-main Discord types in extensions/discord/src/monitor/provider.lifecycle.test.ts
  • Land commit: 3917b1d
  • Merge commit: 9f8c4ef

Thanks @Dhi13man!

@Dhi13man

Copy link
Copy Markdown
Contributor Author

Happy to solve a problem for something that has solved so many problems for me.

@Dhi13man
Dhi13man deleted the fix/cli-runner-tools-disabled-injection branch March 27, 2026 04:58
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 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: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Isolated cron sessions inherit "Group Chat Context: Tools are disabled" system prompt injection (v2026.3.11)

2 participants