anomalyco / anomalyco/opencode

task tool returns 'Task cancelled' prematurely when model fallback plugin retries subagent

Open
#45,556 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 27, 2026.

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

Description

Bug Description

When a subagent is invoked via the task tool and the primary model fails, the model fallback plugin (@razroo/opencode-model-fallback) transparently retries with a fallback model. However, the task tool returns "Task cancelled" to the parent agent in under 1 second -- even though the subagent continues executing successfully in the background with the fallback model.

Steps to Reproduce

  1. Configure a subagent (e.g. business-analyst) with fallback_models in opencode.jsonc
  2. Have the primary model fail (rate limit, timeout, etc.)
  3. The fallback plugin kicks in and replays the request with the fallback model
  4. The subagent session starts and runs to completion
  5. The parent agent receives "error": "Task cancelled" from the task tool almost immediately (~756ms)

Expected Behavior

The task tool should either:

  • Wait for the fallback model to complete and return the actual result
  • Return a status like "Task running with fallback model" instead of "Task cancelled"
  • Provide the subagent session_id so the parent can poll for completion

Actual Behavior

The task tool returns "Task cancelled" in under 1 second, but the subagent session continues running in the background. The parent agent has no way to know the subagent is still executing.

Evidence

From a session JSON export:

{
  "tool": "task",
  "state": {
    "status": "error",
    "error": "Task cancelled",
    "input": {
      "description": "Business Analyst correction task",
      "subagent_type": "business-analyst"
    }
  },
  "metadata": {
    "sessionId": "ses_fbce57090ffeHOGFuETTNxfjKC"
  },
  "time": {
    "start": 1787832209275,
    "end": 1787832210031
  }
}

Duration: 756ms. The subagent session ses_fbce57090ffeHOGFuETTNxfjKC continued executing after this error was returned.

Environment

  • OpenCode version: 1.18.23
  • Platform: Windows
  • Plugin: @razroo/opencode-model-fallback

Impact

Parent agents (especially orchestrators) cannot trust the task tool result when fallback is active. They may:

  • Skip completed work (thinking the task failed)
  • Duplicate work by re-invoking the subagent
  • Do the subagent work manually instead of waiting

Suggested Fix

The task tool should be aware that a fallback plugin may be retrying and should not return "Task cancelled" until the subagent session has actually terminated (success or final failure).

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.