Skip to content

Commit 43c9107

Browse files
committed
fix(tool): fix cancel_task to abort subagent session instead of parent (#54)
1 parent 49e21cc commit 43c9107

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎packages/opencode/src/tool/cancel_task.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const CancelTaskTool = Tool.define<z.ZodObject<{ task_id: z.ZodString }>,
2626
.regex(/^[a-zA-Z0-9_-]+$/)
2727
.describe("The ID of the background task to cancel"),
2828
}),
29-
async execute(params) {
29+
async execute(params, ctx) {
3030
const result = Session.tryCancel(params.task_id)
3131

3232
const response: CancelTaskResult = {

‎packages/opencode/src/tool/task.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ Response Output:
6464

6565
Note: Both modes respect the 5-task limit per session and 10-minute timeout.
6666

67+
Task lifecycle management:
68+
- If new information makes a running task obsolete, cancel it with cancel_task before launching a replacement. Do not leave stale tasks running.
69+
- Use check_task to inspect task status before deciding to cancel or wait.
70+
- When cancelling and re-launching, provide the updated context in the new task's prompt.
71+
6772
Example usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):
6873

6974
<example_agent_descriptions>

0 commit comments

Comments
 (0)