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
- 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)
- 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)
What happened
Running
opencode runcan crash with a TypeError when thetasktool is invoked withoutsubagent_type(e.g. category-only calls, or continuation calls that only passsession_id).Stack trace observed:
The crash happens because
packages/opencode/src/cli/cmd/run.tsassumesinfo.input.subagent_typeis always present:When it is
undefined,Locale.titlecase()throws.Repro
opencode runand cause the model to call thetasktool withoutsubagent_type(common valid cases):task(category="...", ...)(category-only)task(session_id="...", ...)(continuation-only)Expected
opencode runshould never crash; it should render a sensible fallback label whensubagent_typeis missing (e.g. usecategory, or default to "Task").Suggested fix
Guard
subagent_typein the run formatter, e.g.:const agentRaw = info.input.subagent_type ?? info.input.category ?? "task";Locale.titlecase()Environment