Bug Description
When a prompt_async request arrives without explicit agent or model fields (e.g., from Envoy notifications, Legion worker coordination, or any fire-and-forget prompt injection), the session's active agent and model are silently overridden by the default agent's configured defaults.
Steps to Reproduce
- Start a session and set it to a non-default agent and model (e.g., agent=
hephaestus, model=opencode/kimi-k2.5-free)
- Send a
POST /session/:id/prompt_async with only parts (no agent, no model)
- Observe the next assistant turn uses the default agent's configured model, not the session's active model
Expected Behavior
When prompt_async omits agent and model, the session should preserve whatever agent and model were active from the last user message.
Actual Behavior
The session's agent falls back to the default agent config, and the model falls back to that agent's configured model — discarding whatever the user had actively selected.
Root Cause
In packages/opencode/src/session/prompt.ts, createUserMessage() defaulted omitted agent/model from the default agent configuration instead of reading the current session prompt state (most recent user/assistant message). The synthesized user message then became the new source of truth for ACP session replay, silently redirecting the session.
Impact
This actively affects overnight agent coordination: Envoy notifications delivered to sessions via prompt_async can change the session's agent and model, causing unexpected model switches and errors.
Environment
- OpenCode version: 1.4.0-sami
- Affected endpoint:
POST /session/:id/prompt_async
- Also affects:
command() (which reuses prompt())
Bug Description
When a
prompt_asyncrequest arrives without explicitagentormodelfields (e.g., from Envoy notifications, Legion worker coordination, or any fire-and-forget prompt injection), the session's active agent and model are silently overridden by the default agent's configured defaults.Steps to Reproduce
hephaestus, model=opencode/kimi-k2.5-free)POST /session/:id/prompt_asyncwith onlyparts(noagent, nomodel)Expected Behavior
When
prompt_asyncomitsagentandmodel, the session should preserve whatever agent and model were active from the last user message.Actual Behavior
The session's agent falls back to the default agent config, and the model falls back to that agent's configured model — discarding whatever the user had actively selected.
Root Cause
In
packages/opencode/src/session/prompt.ts,createUserMessage()defaulted omittedagent/modelfrom the default agent configuration instead of reading the current session prompt state (most recent user/assistant message). The synthesized user message then became the new source of truth for ACP session replay, silently redirecting the session.Impact
This actively affects overnight agent coordination: Envoy notifications delivered to sessions via
prompt_asynccan change the session's agent and model, causing unexpected model switches and errors.Environment
POST /session/:id/prompt_asynccommand()(which reusesprompt())