diff --git a/packages/coding-agent/src/prompts/tools/bash.md b/packages/coding-agent/src/prompts/tools/bash.md index f30f50662..bcdece577 100644 --- a/packages/coding-agent/src/prompts/tools/bash.md +++ b/packages/coding-agent/src/prompts/tools/bash.md @@ -10,16 +10,6 @@ Executes bash command in shell session for terminal operations like git, bun, ca {{#if asyncEnabled}} - Use `async: true` for long-running commands when you don't need immediate output; the call returns a background job ID and the result is delivered automatically as a follow-up. {{/if}} -{{#if autoBackgroundEnabled}} -- Long-running non-PTY commands may auto-background after ~{{autoBackgroundThresholdSeconds}}s and continue as background jobs. -{{/if}} -{{#if asyncEnabled}} -- Inspect background jobs with `read jobs://` (`read jobs://` for detail). To wait for results, call `job` (with `poll`) — do NOT poll `read jobs://` in a loop or yield and hope for delivery. -{{else}} -{{#if autoBackgroundEnabled}} -- For auto-backgrounded jobs, inspect with `read jobs://` and call `job` (with `poll`) to wait — do NOT poll in a loop. -{{/if}} -{{/if}} diff --git a/packages/coding-agent/src/prompts/tools/job.md b/packages/coding-agent/src/prompts/tools/job.md index 561e13094..298bd009d 100644 --- a/packages/coding-agent/src/prompts/tools/job.md +++ b/packages/coding-agent/src/prompts/tools/job.md @@ -1,11 +1,11 @@ Manages background jobs: poll to wait for completion, cancel to stop running jobs. -You **MUST** use the `job` tool (in a loop, if necessary) instead of manually reading in a loop or issuing sleep commands. +Background job results are delivered automatically when possible. Read the `jobs://` URI, or `jobs://` for detail, only for inspection when useful — not for waiting. -Pass `poll` to wait for one or more background jobs to finalize. If the timeout elapses before any job changes state, it returns the current snapshot (still-running jobs and any already-completed deliveries) without erroring — call `job` again to keep waiting. Calling with no `poll` and no `cancel` waits on every running background job. +If you are genuinely blocked on a background job result, pass `poll` to wait for one or more jobs to finalize. If the timeout elapses before any job changes state, it returns the current snapshot (still-running jobs and any already-completed deliveries) without erroring. Calling with no `poll` and no `cancel` waits on every running background job. -You **MUST NOT** poll the same job repeatedly without evidence of progress. Between calls, inspect `read jobs://` to confirm new output or activity. If a job is stalled, has hung, or is producing nothing useful, cancel it via `cancel` and try a different approach instead of waiting indefinitely. +You **MUST NOT** wait by repeatedly reading the `jobs://` URI or `jobs://` URI. If a job is stalled, has hung, or is producing nothing useful, cancel it via `cancel` and try a different approach instead of waiting indefinitely. -Pass `cancel` to stop one or more running background jobs (started via async tool execution or bash auto-backgrounding). You **SHOULD** cancel jobs that are no longer needed or stuck. You **MAY** inspect jobs first with `read jobs://` or `read jobs://`. +Pass `cancel` to stop one or more running background jobs (started via async tool execution or bash auto-backgrounding). You **SHOULD** cancel jobs that are no longer needed or stuck. You **MAY** inspect the `jobs://` URI, or `jobs://`, first. `poll` and `cancel` may be combined in a single call: cancellations apply first, then polling waits on the remaining ids. When only `cancel` is provided the call returns immediately without waiting. diff --git a/packages/coding-agent/src/prompts/tools/task.md b/packages/coding-agent/src/prompts/tools/task.md index da6eeb251..e338fb241 100644 --- a/packages/coding-agent/src/prompts/tools/task.md +++ b/packages/coding-agent/src/prompts/tools/task.md @@ -1,8 +1,9 @@ Launches subagents to parallelize workflows. {{#if asyncEnabled}} -- `read jobs://` for state, `read jobs://` for detail. -- Use `job` (with `poll`) to wait. **MUST NOT** poll `read jobs://` in a loop. +- Results are delivered automatically when complete. +- If genuinely blocked on task completion, wait with `job` using `poll`; otherwise continue with another task when possible. +- You can also read the `jobs://` URI for manager state and `jobs://` for detail only when inspection is useful. {{/if}} Subagents have no conversation history. Every fact, file path, and decision they need **MUST** be explicit in {{#if contextEnabled}}`context` or `assignment`{{else}}each `assignment`{{/if}}. diff --git a/packages/coding-agent/src/tools/bash.ts b/packages/coding-agent/src/tools/bash.ts index 62a49ce0f..9a4776ea5 100644 --- a/packages/coding-agent/src/tools/bash.ts +++ b/packages/coding-agent/src/tools/bash.ts @@ -326,7 +326,9 @@ export class BashTool implements AgentTool { } lines.push(`Background job ${jobId} started: ${label}`); lines.push("Result will be delivered automatically when complete."); - lines.push(`If blocked, use \`job\` with \`poll\`; inspect with \`read jobs://${jobId}\` or cancel with \`job\`.`); + lines.push( + `You can use \`job\` to poll until complete, but prefer to continue with another task in the meanwhile if it's not blocking.`, + ); return { content: [{ type: "text", text: lines.join("\n") }], details,