From 17a148c8a847d4270bf22201c8cf0f79f4b8ce66 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 03:51:32 +0100 Subject: [PATCH] fix: always include long-wait polling guidance in prompt --- src/agents/system-prompt.e2e.test.ts | 3 +++ src/agents/system-prompt.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/agents/system-prompt.e2e.test.ts b/src/agents/system-prompt.e2e.test.ts index 65f8d7852d4..2fcd4220224 100644 --- a/src/agents/system-prompt.e2e.test.ts +++ b/src/agents/system-prompt.e2e.test.ts @@ -120,6 +120,9 @@ describe("buildAgentSystemPrompt", () => { workspaceDir: "/tmp/openclaw", }); + expect(prompt).toContain( + "For long waits, avoid rapid poll loops: use exec with enough yieldMs or process(action=poll, timeout=).", + ); expect(prompt).toContain("Completion is push-based: it will auto-announce when done."); expect(prompt).toContain("Do not poll `subagents list` / `sessions_list` in a loop"); }); diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index f6b4c0625fc..0c9fe921a33 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -413,7 +413,6 @@ export function buildAgentSystemPrompt(params: { "- apply_patch: apply multi-file patches", `- ${execToolName}: run shell commands (supports background via yieldMs/background)`, `- ${processToolName}: manage background exec sessions`, - `- For long waits, avoid rapid poll loops: use ${execToolName} with enough yieldMs or ${processToolName}(action=poll, timeout=).`, "- browser: control OpenClaw's dedicated browser", "- canvas: present/eval/snapshot the Canvas", "- nodes: list/describe/notify/camera/screen on paired nodes", @@ -425,6 +424,7 @@ export function buildAgentSystemPrompt(params: { '- session_status: show usage/time/model state and answer "what model are we using?"', ].join("\n"), "TOOLS.md does not control tool availability; it is user guidance for how to use external tools.", + `For long waits, avoid rapid poll loops: use ${execToolName} with enough yieldMs or ${processToolName}(action=poll, timeout=).`, "If a task is more complex or takes longer, spawn a sub-agent. Completion is push-based: it will auto-announce when done.", "Do not poll `subagents list` / `sessions_list` in a loop; only check status on-demand (for intervention, debugging, or when explicitly asked).", "",