Subagent AI_APICallError is silently swallowed, causing session to hang #9213

Open
opened 2026-02-16 18:11:55 -05:00 by yindo · 0 comments
Owner

Originally created by @unthingable on GitHub (Feb 12, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

When a subagent encounters an AI_APICallError (e.g., due to an invalid model ID), the error is logged at ERROR level but never surfaced to the user or returned to the parent agent as a tool result. The subagent session silently dies, and the parent session appears stuck/loading indefinitely.

By contrast, when a primary agent hits the same error, it is surfaced clearly in the TUI:

Error: model: claude-sonnet-4-5-latest

Steps to reproduce

  1. Configure a custom model alias with an invalid model ID in opencode.jsonc:
"provider": {
  "anthropic": {
    "models": {
      "sonnet": { "id": "claude-sonnet-4-5-INVALID" }
    }
  }
}
  1. Define any subagent that uses this model (JSON or markdown):
"agent": {
  "my-agent": {
    "description": "Test agent",
    "mode": "subagent",
    "model": "anthropic/sonnet"
  }
}
  1. In a session, have the primary agent invoke the subagent via the task tool.

  2. The subagent's LLM call fails with AI_APICallError. The error appears in --print-logs output:

ERROR service=session.processor error=model: claude-sonnet-4-5-INVALID stack="AI_APICallError: model: claude-sonnet-4-5-INVALID\n    at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+.../dist/index.mjs:936:18)..."
  1. But the parent session never receives the error — it just hangs waiting for the subagent.

Expected behavior

  • The error should be returned to the parent agent as a failed tool result, so it can report the issue or attempt recovery.
  • The TUI should surface the subagent error to the user (e.g., in the subagent panel or as a notification).

Actual behavior

  • The AI_APICallError is logged but swallowed.
  • The subagent session silently dies.
  • The parent session hangs indefinitely waiting for a response that will never come.
  • The user has no indication of what went wrong without checking --print-logs or log files.

Related issues

  • #11865 — subagents getting stuck with no timeout/retry (different provider, similar symptom)
  • #10802 — parent session appears stuck when subagent is blocked (TUI visibility)

OpenCode version

1.1.53

Operating System

macOS (Darwin 24.6.0)

Originally created by @unthingable on GitHub (Feb 12, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description When a subagent encounters an `AI_APICallError` (e.g., due to an invalid model ID), the error is logged at ERROR level but never surfaced to the user or returned to the parent agent as a tool result. The subagent session silently dies, and the parent session appears stuck/loading indefinitely. By contrast, when a **primary** agent hits the same error, it is surfaced clearly in the TUI: ``` Error: model: claude-sonnet-4-5-latest ``` ### Steps to reproduce 1. Configure a custom model alias with an invalid model ID in `opencode.jsonc`: ```jsonc "provider": { "anthropic": { "models": { "sonnet": { "id": "claude-sonnet-4-5-INVALID" } } } } ``` 2. Define any subagent that uses this model (JSON or markdown): ```jsonc "agent": { "my-agent": { "description": "Test agent", "mode": "subagent", "model": "anthropic/sonnet" } } ``` 3. In a session, have the primary agent invoke the subagent via the task tool. 4. The subagent's LLM call fails with `AI_APICallError`. The error appears in `--print-logs` output: ``` ERROR service=session.processor error=model: claude-sonnet-4-5-INVALID stack="AI_APICallError: model: claude-sonnet-4-5-INVALID\n at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+.../dist/index.mjs:936:18)..." ``` 5. But the parent session never receives the error — it just hangs waiting for the subagent. ### Expected behavior - The error should be returned to the parent agent as a failed tool result, so it can report the issue or attempt recovery. - The TUI should surface the subagent error to the user (e.g., in the subagent panel or as a notification). ### Actual behavior - The `AI_APICallError` is logged but swallowed. - The subagent session silently dies. - The parent session hangs indefinitely waiting for a response that will never come. - The user has no indication of what went wrong without checking `--print-logs` or log files. ### Related issues - #11865 — subagents getting stuck with no timeout/retry (different provider, similar symptom) - #10802 — parent session appears stuck when subagent is blocked (TUI visibility) ### OpenCode version 1.1.53 ### Operating System macOS (Darwin 24.6.0)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9213