anomalyco / anomalyco/opencode
[Bug] Esc abort of task tool still loses task_id on v1.18.21 — v1.18.20 fix incomplete
@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):
- Primary dispatches sub-agent via
tasktool (e.g. "Write 200 line story, numbered 1..200") - Wait ~15s (well past session creation, TUI shows sub-agent running)
- Press
Esconce (TUI shows "esc again to interrupt") - Parent receives generic
Task cancelled— notask_id: ses_...line - Child session DOES exist in DB with
MessageAbortedError: Aborted(verified viaopencode db "select id from session order by time_created desc"), e.g.ses_fca2e2e1fffew5cAkpmn6IgDgJandses_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_fca390730ffeUxcxDUwJB9mr5Jlast messages havefinish:"tool-calls"but notask_resultwith task_id - Child sessions:
ses_fca376712ffe8yo4PsY76GyGSW(1787608733965) andses_fca2e2e1fffew5cAkpmn6IgDgJ(1787609338370) bothMessageAbortedError: Aborted, 0 tokens v1.18.20changelog 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
opencodewith any model, send prompt that triggerstasktool (e.g. "Explore codebase and write 200 lines story")- While sub-agent running, press Esc after 15s
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.