You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: undefined is not an object (evaluating 'agent.name') in createUserMessage #11798
TypeError: undefined is not an object (evaluating 'agent.name')
at createUserMessage (src/session/prompt.ts:838:14)
Root Cause
In createUserMessage, Agent.get() can return undefined when the agent name cannot be resolved, but the code proceeds to access agent.name without a null check.
asyncfunctioncreateUserMessage(input: PromptInput){constagent=awaitAgent.get(input.agent??(awaitAgent.defaultAgent()))// agent can be undefined here if:// 1. input.agent is invalid// 2. defaultAgent() returns an invalid name// 3. Agent.get() fails to find the agent// Later in the code:agent: agent.name,// TypeError when agent is undefined
Suggested Fix
Add null check after Agent.get():
constagent=awaitAgent.get(input.agent??(awaitAgent.defaultAgent()))if(!agent){thrownewError(`Agent not found: ${input.agent??'default'}`)}
Environment
OpenCode version: 1.1.48
Platform: macOS (darwin-arm64)
Reproduction
Occurs intermittently, likely when custom agent configuration is missing or malformed.
The common pattern across these issues suggests a systemic problem with insufficient null checking when agent objects return undefined. Consider consolidating these under a larger initiative to add null-safety checks throughout the codebase, particularly in Agent.get(), local.agent.current(), and session prompt handling.
Feel free to ignore if your specific case has unique requirements.
Activity
github-actions commentedon Feb 2, 2026
This issue might be a duplicate of existing issues. Please check:
The common pattern across these issues suggests a systemic problem with insufficient null checking when agent objects return undefined. Consider consolidating these under a larger initiative to add null-safety checks throughout the codebase, particularly in Agent.get(), local.agent.current(), and session prompt handling.
Feel free to ignore if your specific case has unique requirements.
dead-pool-aka-wilson commentedon Feb 2, 2026
Duplicate of #11110 / #7918 - same root cause: agent.current() returning undefined