Skip to content

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

@unthingable

Description

@unthingable

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/@[email protected]+.../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

OpenCode version

1.1.53

Operating System

macOS (Darwin 24.6.0)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions