anomalyco / anomalyco/opencode

agent list crashes with "undefined is not an object (evaluating 'a.name')" when the config has a non-empty references block

Open
#48,809 1 comment 1 reaction 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 13, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

opencode agent list crashes when the config contains a non-empty references block:

Error: Unexpected error

undefined is not an object (evaluating 'a.name')

The same config without references works. The HTTP agent endpoint fails the same way through Agent.list, so clients that request the agent list at session start break. I hit this through T3 Code, which logs prompt_async failed with Cause([Die(TypeError: undefined is not an object (evaluating 'a.name'))]).

Environment
  • opencode 1.18.30, Homebrew formula revision 1.18.30_1, macOS arm64
  • npm latest reports 1.18.30 as well
  • --pure does not change the result
Minimal reproduction
mkdir -p /tmp/oc-repro/opencode
printf '%s' '{"references":{"a":{"path":"/tmp"}}}' > /tmp/oc-repro/opencode/opencode.json
cd /tmp && XDG_CONFIG_HOME=/tmp/oc-repro opencode agent list --pure

The command prints the error instead of an agent list. The XDG override keeps the test away from an existing config.

Variation matrix
config result
empty config dir works
{"references":{}} works
{"references":{"a":{"path":"/tmp"}}} crash
{"references":{"a":{"path":"/tmp","description":"d"}}} crash
{"references":{"a":{"name":"a","path":"/tmp","description":"d"}}} crash
{"mcp":{"noop":{"type":"local","command":["/usr/bin/true"],"enabled":false}}} works

An array under references is rejected by the schema before runtime (Expected object | undefined, got [...] references), so the object form is the intended shape.

Stack (server-side, 1.18.30_1 build)
TypeError: undefined is not an object (evaluating 'a.name')
    at resolve (/$bunfs/root/chunk-36bwgd4p.js:2:1659)
    at a (/$bunfs/root/chunk-36bwgd4p.js:2:936)
    at map (native:1:11)
    at <anonymous> (/$bunfs/root/chunk-36bwgd4p.js:2:1626)
    at a (/$bunfs/root/chunk-36bwgd4p.js:2:1166)
    at map (native:1:11)
    at <anonymous> (/$bunfs/root/chunk-36bwgd4p.js:2:1626)
    at a (/$bunfs/root/chunk-36bwgd4p.js:2:1166)
    at map (native:1:11)
    at <anonymous> (/$bunfs/root/chunk-36bwgd4p.js:2:1390)
    at Agent.state (/$bunfs/root/chunk-y98svhg6.js:2:3738)
    at Agent.state (definition) (/$bunfs/root/chunk-nsh4n3eh.js:14:963)
    at Agent.list (/$bunfs/root/chunk-bg0ps6br.js:5:24963)
    at Agent.list (definition) (/$bunfs/root/chunk-nsh4n3eh.js:14:5247)
    at InstanceHttpApi.agent (/$bunfs/root/chunk-bg0ps6br.js:4:109006)
    at InstanceHttpApi.agent (definition) (/$bunfs/root/chunk-bg0ps6br.js:5:24906)
    at Server.listen (/$bunfs/root/chunk-bg0ps6br.js:8:13200)
    at Server.listen (definition) (/$bunfs/root/chunk-bg0ps6br.js:8:13306)
Expected

opencode agent list lists the agents and resolves or ignores the references entries.

Notes
  • The same setup worked before today's Homebrew update of opencode. Homebrew removed the older Cellar entry, so I cannot quote the exact previous version string.
  • An empty references: {} passes; any entry crashes, with or without description and with or without name.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.