From 35c2a68ef6b8996d0f06a81d005ea2e1406b5f38 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Fri, 25 Sep 2026 21:43:23 -0500 Subject: [PATCH] fix(core): tighten background shell polling guidance --- packages/core/src/tool/plugin/shell.ts | 2 +- packages/core/test/tool-shell.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/tool/plugin/shell.ts b/packages/core/src/tool/plugin/shell.ts index 87be4c9d165..d8d52720465 100644 --- a/packages/core/src/tool/plugin/shell.ts +++ b/packages/core/src/tool/plugin/shell.ts @@ -23,7 +23,7 @@ export const name = "shell" export const DEFAULT_TIMEOUT_MS = 2 * 60 * 1_000 const BACKGROUND_INSTRUCTION = - "You will be notified automatically when the command finishes. The notification will include the command's output. Unless the user explicitly asks otherwise, DO NOT poll for completion, even if you need the final result to continue. Repeatedly sleeping and reading or searching the output file is polling, not useful work. You may read the current output if it lets you do useful work now, but do not repeatedly check it while waiting for the command to finish. Keep working on anything that does not depend on the result. If you have nothing else to do, end your response; you will be resumed automatically when the command finishes." + "You will automatically receive a notification with the command's output when it finishes. DO NOT poll or check on the command while it runs, even if your next step needs its output. NEVER use `sleep`, `ps`, or `pgrep` to wait for it. Every check wastes a turn. Continue with any work that does not depend on the result. If you have nothing else to do, end your turn and the notification will resume you. The output file shown above contains the output so far. Read it only when your work needs its contents. NEVER read it to check whether the command has finished or how far it has gotten." const OS = process.platform === "darwin" ? "macOS" diff --git a/packages/core/test/tool-shell.test.ts b/packages/core/test/tool-shell.test.ts index 226c716b190..c45e97fa1f0 100644 --- a/packages/core/test/tool-shell.test.ts +++ b/packages/core/test/tool-shell.test.ts @@ -1462,7 +1462,7 @@ describe("ShellTool", () => { }, { type: "text", - text: "You will be notified automatically when the command finishes. The notification will include the command's output. Unless the user explicitly asks otherwise, DO NOT poll for completion, even if you need the final result to continue. Repeatedly sleeping and reading or searching the output file is polling, not useful work. You may read the current output if it lets you do useful work now, but do not repeatedly check it while waiting for the command to finish. Keep working on anything that does not depend on the result. If you have nothing else to do, end your response; you will be resumed automatically when the command finishes.", + text: "You will automatically receive a notification with the command's output when it finishes. DO NOT poll or check on the command while it runs, even if your next step needs its output. NEVER use `sleep`, `ps`, or `pgrep` to wait for it. Every check wastes a turn. Continue with any work that does not depend on the result. If you have nothing else to do, end your turn and the notification will resume you. The output file shown above contains the output so far. Read it only when your work needs its contents. NEVER read it to check whether the command has finished or how far it has gotten.", }, ]) expect((yield* shell.list()).map((info) => info.id)).toContain(id) @@ -1728,7 +1728,7 @@ describe("ShellTool", () => { }) expect(settled.content?.[1]).toEqual({ type: "text", - text: "You will be notified automatically when the command finishes. The notification will include the command's output. Unless the user explicitly asks otherwise, DO NOT poll for completion, even if you need the final result to continue. Repeatedly sleeping and reading or searching the output file is polling, not useful work. You may read the current output if it lets you do useful work now, but do not repeatedly check it while waiting for the command to finish. Keep working on anything that does not depend on the result. If you have nothing else to do, end your response; you will be resumed automatically when the command finishes.", + text: "You will automatically receive a notification with the command's output when it finishes. DO NOT poll or check on the command while it runs, even if your next step needs its output. NEVER use `sleep`, `ps`, or `pgrep` to wait for it. Every check wastes a turn. Continue with any work that does not depend on the result. If you have nothing else to do, end your turn and the notification will resume you. The output file shown above contains the output so far. Read it only when your work needs its contents. NEVER read it to check whether the command has finished or how far it has gotten.", }) yield* Effect.sleep(Duration.millis(100)) expect((yield* shell.get(id)).status).toBe("running")