Crash when local.agent.current() returns undefined during startup/auth #4809

Open
opened 2026-02-16 17:45:31 -05:00 by yindo · 7 comments
Owner

Originally created by @tdawe1 on GitHub (Jan 12, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

OpenCode crashes with TypeError: undefined is not an object when:

  1. Using authentication plugins like opencode-antigravity-auth
  2. The agents array is empty or not yet loaded during startup

Stack Traces

TypeError: undefined is not an object (evaluating 'local.agent.current().name') at (src/cli/cmd/tui/component/prompt/index.tsx:840)

TypeError: undefined is not an object (evaluating 'a6.name')
at (src/cli/cmd/tui/context/local.tsx:151)

Root Cause

Multiple places in prompt/index.tsx and local.tsx access .name on potentially undefined objects.

Environment

  • OpenCode version: 1.1.13
  • OS: Arch Linux
Originally created by @tdawe1 on GitHub (Jan 12, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description OpenCode crashes with `TypeError: undefined is not an object` when: 1. Using authentication plugins like `opencode-antigravity-auth` 2. The agents array is empty or not yet loaded during startup ### Stack Traces TypeError: undefined is not an object (evaluating 'local.agent.current().name') at (src/cli/cmd/tui/component/prompt/index.tsx:840) TypeError: undefined is not an object (evaluating 'a6.name') at (src/cli/cmd/tui/context/local.tsx:151) ### Root Cause Multiple places in [prompt/index.tsx](cci:7://file:///tmp/opencode-src/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx:0:0-0:0) and [local.tsx](cci:7://file:///tmp/opencode-src/packages/opencode/src/cli/cmd/tui/context/local.tsx:0:0-0:0) access `.name` on potentially undefined objects. ### Environment - OpenCode version: 1.1.13 - OS: Arch Linux
yindo added the opentui label 2026-02-16 17:45:31 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 12, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7550: opentui: TUI crashes after successful native OpenAI account connection (TypeError: local.agent.current() is undefined)
  • #7913: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - when connecting provider -> vercel ai gate
  • #7913: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')
  • #7770: openai auth after v1.1.11 fatal error
  • #7765: OpenAI auth had fatal error after successful auth
  • #7754: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')
  • #7727: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')
  • #7686: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')
  • #7630: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')
  • #7628: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - When login copilot

All of these involve the same error: 'local.agent.current()' returning undefined, occurring during authentication or provider connection. They all share similar stack traces pointing to prompt/index.tsx:840.

Feel free to ignore if this addresses your specific case differently than these others.

@github-actions[bot] commented on GitHub (Jan 12, 2026): This issue might be a duplicate of existing issues. Please check: - #7550: opentui: TUI crashes after successful native OpenAI account connection (TypeError: local.agent.current() is undefined) - #7913: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - when connecting provider -> vercel ai gate - #7913: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - #7770: openai auth after v1.1.11 fatal error - #7765: OpenAI auth had fatal error after successful auth - #7754: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - #7727: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - #7686: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - #7630: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - #7628: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name') - When login copilot All of these involve the same error: 'local.agent.current()' returning undefined, occurring during authentication or provider connection. They all share similar stack traces pointing to prompt/index.tsx:840. Feel free to ignore if this addresses your specific case differently than these others.
Author
Owner

@dhruvkej9 commented on GitHub (Jan 15, 2026):

@rekram1-node @thdxr This issue is also on version 1.1.21

Occured for me while doing /connect and after the github copilot auth was successful

@dhruvkej9 commented on GitHub (Jan 15, 2026): @rekram1-node @thdxr This issue is also on version 1.1.21 Occured for me while doing /connect and after the github copilot auth was successful
Author
Owner

@rekram1-node commented on GitHub (Jan 15, 2026):

Yeah trying to figure this out is annoying, cant replicate at all

@rekram1-node commented on GitHub (Jan 15, 2026): Yeah trying to figure this out is annoying, cant replicate at all
Author
Owner

@dhruvkej9 commented on GitHub (Jan 15, 2026):

Yeah trying to figure this out is annoying, cant replicate at all

Try doing /connect with copilot models using opencode-copilot-auth@0.0.11 on opencode@1.1.21

after entering code on github website, when you comeback to opencode you should see this.

@dhruvkej9 commented on GitHub (Jan 15, 2026): > Yeah trying to figure this out is annoying, cant replicate at all > Try doing /connect with copilot models using opencode-copilot-auth@0.0.11 on opencode@1.1.21 after entering code on github website, when you comeback to opencode you should see this.
Author
Owner

@rekram1-node commented on GitHub (Jan 15, 2026):

Yeah did this several times, cannot replicate.

What OS are you using

@rekram1-node commented on GitHub (Jan 15, 2026): Yeah did this several times, cannot replicate. What OS are you using
Author
Owner

@dhruvkej9 commented on GitHub (Jan 15, 2026):

Yeah did this several times, cannot replicate.

What OS are you using

I am using Ubuntu 24.04 on WSL2 in Windows 11

(Windows Terminal)

@dhruvkej9 commented on GitHub (Jan 15, 2026): > Yeah did this several times, cannot replicate. > > What OS are you using I am using Ubuntu 24.04 on WSL2 in Windows 11 (Windows Terminal)
Author
Owner

@jamshidkhaksaar commented on GitHub (Jan 21, 2026):

is this issue resolved?

@jamshidkhaksaar commented on GitHub (Jan 21, 2026): is this issue resolved?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4809