opencode run crashes when task tool input lacks subagent_type #8982

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

Originally created by @Hannu6 on GitHub (Feb 10, 2026).

Originally assigned to: @rekram1-node on GitHub.

What happened

Running opencode run can crash with a TypeError when the task tool is invoked without subagent_type (e.g. category-only calls, or continuation calls that only pass session_id).

Stack trace observed:

TypeError: undefined is not an object (evaluating 'str.replace')
  at titlecase (packages/opencode/src/util/locale.ts:3:12)
  at task (packages/opencode/src/cli/cmd/run.ts:170:24)
  at loop (packages/opencode/src/cli/cmd/run.ts:455:15)

The crash happens because packages/opencode/src/cli/cmd/run.ts assumes info.input.subagent_type is always present:

const agent = Locale.titlecase(info.input.subagent_type)

When it is undefined, Locale.titlecase() throws.

Repro

  1. Run opencode run and cause the model to call the task tool without subagent_type (common valid cases):
    • task(category="...", ...) (category-only)
    • task(session_id="...", ...) (continuation-only)
  2. Observe the CLI crash above.

Expected

opencode run should never crash; it should render a sensible fallback label when subagent_type is missing (e.g. use category, or default to "Task").

Suggested fix

Guard subagent_type in the run formatter, e.g.:

  • const agentRaw = info.input.subagent_type ?? info.input.category ?? "task";
  • pass a safe string to Locale.titlecase()

Environment

  • opencode: 1.1.53 (local dev wrapper)
  • oh-my-opencode: 3.4.0
  • macOS (darwin)
Originally created by @Hannu6 on GitHub (Feb 10, 2026). Originally assigned to: @rekram1-node on GitHub. ## What happened Running `opencode run` can crash with a TypeError when the `task` tool is invoked without `subagent_type` (e.g. category-only calls, or continuation calls that only pass `session_id`). Stack trace observed: ``` TypeError: undefined is not an object (evaluating 'str.replace') at titlecase (packages/opencode/src/util/locale.ts:3:12) at task (packages/opencode/src/cli/cmd/run.ts:170:24) at loop (packages/opencode/src/cli/cmd/run.ts:455:15) ``` The crash happens because `packages/opencode/src/cli/cmd/run.ts` assumes `info.input.subagent_type` is always present: ```ts const agent = Locale.titlecase(info.input.subagent_type) ``` When it is `undefined`, `Locale.titlecase()` throws. ## Repro 1. Run `opencode run` and cause the model to call the `task` tool without `subagent_type` (common valid cases): - `task(category="...", ...)` (category-only) - `task(session_id="...", ...)` (continuation-only) 2. Observe the CLI crash above. ## Expected `opencode run` should never crash; it should render a sensible fallback label when `subagent_type` is missing (e.g. use `category`, or default to "Task"). ## Suggested fix Guard `subagent_type` in the run formatter, e.g.: - `const agentRaw = info.input.subagent_type ?? info.input.category ?? "task";` - pass a safe string to `Locale.titlecase()` ## Environment - opencode: 1.1.53 (local dev wrapper) - oh-my-opencode: 3.4.0 - macOS (darwin)
yindo closed this issue 2026-02-16 18:11:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8982