anomalyco / anomalyco/opencode

[Bug] Esc abort of task tool still loses task_id on v1.18.21 — v1.18.20 fix incomplete

Open
#44,791 1 comment 2 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 24, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

After the fix in v1.18.20 ("Surface failed subagent tool calls with a resumable task_id"), cancelling a task sub-agent with Esc still returns only Task cancelled / Tool execution aborted with no task_id. The child session is preserved in DB but parent has no handle to resume.

Repro on 1.18.21 (includes v1.18.20):

  1. Primary dispatches sub-agent via task tool (e.g. "Write 200 line story, numbered 1..200")
  2. Wait ~15s (well past session creation, TUI shows sub-agent running)
  3. Press Esc once (TUI shows "esc again to interrupt")
  4. Parent receives generic Task cancelledno task_id: ses_... line
  5. Child session DOES exist in DB with MessageAbortedError: Aborted (verified via opencode db "select id from session order by time_created desc"), e.g. ses_fca2e2e1fffew5cAkpmn6IgDgJ and ses_fca376712ffe8yo4PsY76GyGSW — but LLM cannot reference it.

Expected (per #13910):
task_id: ses_... (sub-agent session preserved — reuse to retry/inspect)
<task_error>Tool execution aborted</task_error>
and resume via task(task_id="ses_...").

Evidence:

  • Parent ses_fca390730ffeUxcxDUwJB9mr5J last messages have finish:"tool-calls" but no task_result with task_id
  • Child sessions: ses_fca376712ffe8yo4PsY76GyGSW (1787608733965) and ses_fca2e2e1fffew5cAkpmn6IgDgJ (1787609338370) both MessageAbortedError: Aborted, 0 tokens
  • v1.18.20 changelog lists "Surface failed subagent tool calls with a resumable task_id" — Esc path still empty

Suspected root cause: v1.18.20 fix wraps sub-agent internal failures inside tool/task.ts SessionPrompt.prompt() try/catch, but user Esc aborts the parent SessionPrompt.loop() AbortController outside that catch — all pending tools marked error("Tool execution aborted") before wrapper can return session.id. Same as #13910 lines 128-162, abort path not covered.

Suggested fix: ensure session.id is returned even on parent abort, and TUI renders task_id on aborted Task parts (cf. #24756).

Plugins

No response

OpenCode version

1.18.21

Steps to reproduce
  1. opencode with any model, send prompt that triggers task tool (e.g. "Explore codebase and write 200 lines story")
  2. While sub-agent running, press Esc after 15s
  3. Observe parent receives "Task cancelled" with no task_id; check opencode db — child session exists but is unreachable
Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal / PowerShell 7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.