Skip to content

fix(task): return task_id when subagent run errors - #13958

Closed
weiguangli-io wants to merge 1 commit into
anomalyco:devfrom
weiguangli-io:codex/opencode-13910-task-session-id
Closed

fix(task): return task_id when subagent run errors#13958
weiguangli-io wants to merge 1 commit into
anomalyco:devfrom
weiguangli-io:codex/opencode-13910-task-session-id

Conversation

@weiguangli-io

@weiguangli-io weiguangli-io commented Feb 17, 2026

Copy link
Copy Markdown

Fixes #13910

Summary

This keeps the task tool recoverable when a subagent run fails.

  • wrap SessionPrompt.prompt() in packages/opencode/src/tool/task.ts with error handling
  • on error, return structured output that still includes task_id
  • keep success behavior unchanged
  • add focused tests for both success and failure paths

Why

Issue #13910 reports that when subagent execution throws (cancel/timeout/provider error), the parent agent loses the session handle and cannot resume with task_id.

This change guarantees that task_id is always returned, so the parent can retry/inspect the same subagent session.

Fixes #13910

Testing

  • cd packages/opencode && bun test test/tool/task.test.ts
  • cd packages/opencode && bun run typecheck

(Repository-wide pre-push hook typecheck fails in this local environment due missing @typescript/native-preview-darwin-x64, but the package-local checks above passed.)

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@weiguangli-io

Copy link
Copy Markdown
Author

Closing due to inactivity. Happy to reopen if there's interest.

@ELLIOTTCABLE

Copy link
Copy Markdown

There's interest from me, at least; I don't currently see any way to correct an in-flight subagent doing something wrong, without losing all of its context and work?

All three of the approaches I am used to for this in Claude Code seem to be absent:

  • I cannot send a message to a subagent anywhere in the TUI that I could find;
  • the conductor tells me it has no 'message the running subagent' tool to call;
  • and interrupting (which I seem to only be able to do to the whole tree at once, not just the subagent, which feels like another serious oversight) doesn't produce a task_id allowing the parent to resume it with the steering info.

@tamasys

tamasys commented Jul 30, 2026

Copy link
Copy Markdown

@weiguangli-io Interest from me too! Seems crazy that this hasn't been implemented before, it's so frustrating having to choose between losing all subagent context or allowing it to keep running on a misguided path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Task tool loses session ID (task_id) when sub-agent fails or is cancelled — primary agent cannot recover

3 participants