anomalyco / anomalyco/opencode
task tool returns 'Task cancelled' prematurely when model fallback plugin retries subagent
@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
- Configure a subagent (e.g.
business-analyst) withfallback_modelsinopencode.jsonc - Have the primary model fail (rate limit, timeout, etc.)
- The fallback plugin kicks in and replays the request with the fallback model
- The subagent session starts and runs to completion
- The parent agent receives
"error": "Task cancelled"from thetasktool 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_idso 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
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.