Repository navigation
Conversation
Greptile SummaryThis PR fixes a misleading system prompt fallback that fired when all tools were denied by policy (e.g.
Confidence Score: 4/5
Prompt To Fix All With AIThis 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 |
| 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"); |
There was a problem hiding this 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:
{
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.e1479a1 to
cd48f39
Compare
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
db2aed6 to
9f82a78
Compare
9f82a78 to
05577e7
Compare
There was a problem hiding this comment.
💡 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".
| "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", |
There was a problem hiding this comment.
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 👍 / 👎.
05577e7 to
a8f8f98
Compare
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
… session cleanup Made-with: Cursor
784eef3 to
220554b
Compare
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
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:
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
src/agents/system-prompt.tsto:Validation