Repository navigation
fix(agents): handle explicit empty tool lists in system prompt - #59898
martinfrancois wants to merge 1 commit into
Conversation
Greptile SummaryThis PR introduces an Confidence Score: 5/5Safe to merge — the explicit empty-tool fix is correct and well-tested; the one deviation from the stated scope boundary has no production impact. All flagged findings are P2. The primary fix (explicit empty-tool sessions) is implemented correctly with comprehensive test coverage across both prompt construction and report rendering. All production callers provide toolNames explicitly, so the legacy-path behavior change is contained. src/agents/system-prompt.ts — the Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/system-prompt.ts
Line: 574
Comment:
**`### message tool` section now appears unconditionally for omitted-toolNames callers**
`hasMessageTool = !hasExplicitToolList || semanticTools.has("message")` evaluates to `true` whenever `toolNames` is omitted (`hasExplicitToolList = false`), because `!false = true` short-circuits the rest. This causes `includeMessageToolGuidance = true` in the `buildMessagingSection` call, so the `### message tool` subsection renders for every no-toolNames call.
In the old code, that section was gated on `availableTools.has("message")`, which was `false` for no-toolNames callers (since `availableTools` was derived from the empty `canonicalToolNames`). The PR states "Omitted tool lists are kept as close as possible to upstream/main behavior" — this is a quiet deviation from that boundary.
All current production callers (embedded runner, CLI runner, OpenAI extension) explicitly provide `toolNames`, so there is no runtime impact. However, tests that call `buildAgentSystemPrompt` without `toolNames` will now include message-tool guidance they didn't before, and any future caller that omits `toolNames` will get misleading prompt content for sessions that don't have a `message` tool.
How can I resolve this? If you propose a fix, please make it concise.Reviews (5): Last reviewed commit: "fix(agents): handle explicit empty tool ..." | Re-trigger Greptile |
4aea296 to
e0d5fc3
Compare
e0d5fc3 to
a11b8b8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a11b8b82b1
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a11b8b8 to
f5e918c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5e918c64c
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f5e918c to
feabf36
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: feabf3657f
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
feabf36 to
64f6249
Compare
|
Did another live repro run - same result as in the PR description (issue reproducible without the fix - issue is fixed on this branch). |
64f6249 to
5b1620b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b1620b4dd
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
5b1620b to
d1e573f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1e573fa92
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
d1e573f to
8b82429
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b82429ddd
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8b82429 to
e627f8d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e627f8d9c0
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e627f8d to
985dc2d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 985dc2d333
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
985dc2d to
4e02b1e
Compare
|
By the way: Failures on CI are unrelated to my changes and all bot comments are addressed. |
4e02b1e to
2d473f9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d473f9556
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
When active-memory plugin invokes sub-agents with toolsAllow, the tools get filtered to [] in the embedded runner context. Strict OpenAI-compatible providers (DashScope/GLM, Kimi, vLLM) reject tools: [] with HTTP 400. Adds wrapStreamFnStripEmptyTools() as a payload interceptor that: - Strips tools entirely when array is empty - Strips tool_choice when tools is absent Consolidates openclaw#59898, openclaw#66710, openclaw#47947 into a single guard. Fixes openclaw#53174.
|
ClawSweeper PR egg 🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress. Hatch commandComment Hatchability rules:
What is this egg doing here?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks @martinfrancois. Closing this stale implementation branch while keeping #44484 open. The patch targets a removed runner path, uses incorrect skill/tool accounting for an explicitly empty tool list, and introduces compatibility-changing validation without real behavior proof. A replacement should implement the current runner contract and prove the empty-list behavior at the live prompt boundary. |
Summary
Describe the problem and fix in 2-5 bullets:
toolNamesin thetransformSystemPromptcontext, so plugins see the same advertised tool list that the main prompt builder is using.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
git blame, prior PR, issue, or refactor if known): feat(system-prompt): trim prompt noise, gate sections on tool availability, filter skills per agent #25569 is still the closest related upstream work because it distinguishes explicitly empty tool availability from unspecified/default availability, but other code paths still had inconsistent behavior. fix(agents): clarify empty tool availability prompt #53000 addresses similar empty-tools confusion but still keeps a reference tool catalog in the prompt. fix(agents): remove unconditional "Tools are disabled" prompt injection in CLI runner #46214 removes adjacent CLI-runner prompt pollution rather than this exact bug.Regression Test Plan (if applicable)
src/agents/system-prompt.test.tssrc/agents/system-prompt-report.test.tssrc/agents/system-prompt.memory.test.tssrc/agents/cli-runner.spawn.test.tssrc/agents/pi-embedded-runner/system-prompt.test.tssrc/agents/pi-embedded-runner/tool-name-allowlist.test.tssrc/agents/pi-embedded-runner/compaction-runtime-context.test.tsextensions/openai/index.test.tstools.entries = []and no skills blocktoolNamesmust preserve legacy/default prompt behaviorUser-visible / Behavior Changes
Sessions with tools explicitly disabled now behave like true no-tool sessions:
Additional fixes covered by this branch:
Sessions with omitted tool lists and explicit non-empty filtered tool lists are still left close to existing behavior unless a narrow consistency fix required otherwise.
Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
openai-codex/gpt-5.4openclaw agent --localno-toolsagent withtools: { deny: ["*"] }Steps
Create a disposable config copy and add a temporary no-tool agent so the runtime has a truly empty effective tool set:
Run the normal CLI repro against that config:
Expected
tools.entriesshould be[]tools.listCharsshould be0Actual
tools.entries = []tools.listChars = 0skills.promptChars = 0skills.entries = []systemPrompt.chars = 20194No tools are available in this session.tools.entries = []tools.listChars = 0skills.promptChars = 5932skills.entries.length = 11systemPrompt.chars = 30389Evidence
Attach at least one:
Evidence highlights:
tools.entries = []tools.listChars = 0skills.promptChars = 0skills.entries = []systemPrompt.chars = 20194No tools are available in this session.v2026.4.11:tools.entries = []tools.listChars = 0skills.promptChars = 5932skills.entries.length = 11systemPrompt.chars = 30389src/agents/system-prompt.test.tssrc/agents/system-prompt-report.test.tssrc/agents/system-prompt.memory.test.tssrc/agents/cli-runner.spawn.test.tssrc/agents/pi-embedded-runner/system-prompt.test.tssrc/agents/pi-embedded-runner/tool-name-allowlist.test.tssrc/agents/pi-embedded-runner/compaction-runtime-context.test.tsextensions/openai/index.test.ts150tests passed across8filesHuman Verification (required)
What you personally verified (not just CI), and how:
mainandv2026.4.11tools.entries = []andtools.listChars = 0Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations