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
When a user manually selects a model in the OpenCode UI (using the model selector dropdown) and sends a message, the model is immediately overridden back to the OMO agent-configured model (from oh-my-openagent.json → agents.sisyphus.model). The manually selected model is used for the message, but the session reverts to the agent config model.
Root Cause
The bug involves two interacting code paths in the runtime-fallback handler:
1. handleSessionCreated unconditionally overwrites session state
In runtime-fallback/event-handler.ts, handleSessionCreated (around line 111688) always overwrites sessionStates[sessionID] with a new state derived from the session.created event info, without checking if the user has already made a manual model selection.
// Simplified logic:constsessionModel=sessionInfo.model;// e.g., "B" (user selected)constpreferredModel=resolvePreferredSessionModel(...);// "A" (agent config)constfallbackIndex=preferredModel!==model
? getFallbackModelsForSession(...).indexOf(model) : -1;conststate=createFallbackState(fallbackIndex>=0&&preferredModel ? preferredModel : model);// If model B is in the fallback list:if(fallbackIndex>=0){state.currentModel=model;// Bstate.originalModel=preferredModel;// A}sessionStates.set(sessionID,state);
Since the user-selected model B is in the agent's fallback_models list, the handler creates a state where:
originalModel = A (agent config model)
currentModel = B (user-selected, but treated as "fallback")
2. createChatMessageHandler2 interprets the state as an active fallback
In runtime-fallback/chat-message-handler.ts, the chat.message handler (around line 111305) processes each message and at lines 111348-111364:
constactiveModel=state.currentModel;// Bif(activeModel===state.originalModel)return;// B !== A → continues// ❌ Applies "fallback override" — actually reverts to agent config!output.message.model={providerID: parts[0],modelID: parts.slice(1).join("/")};// Forces model back to A
The handler interprets currentModel !== originalModel as "a fallback is active" and overrides output.message.model with the agent config model — even when the user manually selected the current model.
Event timing scenario
1. User selects model B in UI, sends message
2. session.created fires → handleSessionCreated
→ state = { originalModel: A, currentModel: B }
→ B is treated as "fallback" because it's in fallback_models list
3. chat.message fires → runtime-fallback handler
→ input.model = B, state.currentModel = B
→ requestedModel === state.currentModel → no "manual change" detected
→ activeModel (B) !== originalModel (A) → treats as fallback override
→ output.message.model = A ← BUG!
Expected Behavior
When a user manually selects a model in the UI:
The session state should respect the user's choice, not treat it as a fallback
handleSessionCreated should not overwrite session state that was set by a user's manual model selection
createChatMessageHandler2 should distinguish between "fallback due to error" and "user manually selected a different model"
Suggested Fix
There are two approaches:
Approach A: Fix handleSessionCreated to not overwrite on manual selection
In the session.created event handler, check if the user already has a pending model selection before overwriting. If chat.message already processed the message and detected a manual model change (reset state), session.created should not overwrite that.
Approach B: Fix createChatMessageHandler2 to respect user selection
When activeModel !== originalModel:
Check if input.model contains the user's UI selection
If the "fallback" model matches the user's UI choice, it is NOT a fallback — it is a user preference
Only apply the model override when the model change was due to an API error, not a user action
A minimal fix would be in createChatMessageHandler2: add a check that if input.model matches state.currentModel and differs from state.originalModel, the user intentionally chose this model — do not override.
// Additional check before applying fallback override:if(input.model){constrequestedModel=`${input.model.providerID}/${input.model.modelID}`;if(requestedModel===state.currentModel&&requestedModel!==state.originalModel){// User intentionally selected this model — not a fallbackreturn;}}
Additional Context
OMO version: 4.15.0
The bug occurs regardless of which models are involved, as long as the UI-selected model is in the agent's fallback_models list
The bug does NOT occur for agents without explicit model config (because hasExplicitAgentModelOverride returns false, causing a different code path that does not interact with session state)
Bug Description
When a user manually selects a model in the OpenCode UI (using the model selector dropdown) and sends a message, the model is immediately overridden back to the OMO agent-configured model (from
oh-my-openagent.json→agents.sisyphus.model). The manually selected model is used for the message, but the session reverts to the agent config model.Root Cause
The bug involves two interacting code paths in the runtime-fallback handler:
1.
handleSessionCreatedunconditionally overwrites session stateIn
runtime-fallback/event-handler.ts,handleSessionCreated(around line 111688) always overwritessessionStates[sessionID]with a new state derived from thesession.createdevent info, without checking if the user has already made a manual model selection.Since the user-selected model B is in the agent's
fallback_modelslist, the handler creates a state where:originalModel = A(agent config model)currentModel = B(user-selected, but treated as "fallback")2.
createChatMessageHandler2interprets the state as an active fallbackIn
runtime-fallback/chat-message-handler.ts, the chat.message handler (around line 111305) processes each message and at lines 111348-111364:The handler interprets
currentModel !== originalModelas "a fallback is active" and overridesoutput.message.modelwith the agent config model — even when the user manually selected the current model.Event timing scenario
Expected Behavior
When a user manually selects a model in the UI:
handleSessionCreatedshould not overwrite session state that was set by a user's manual model selectioncreateChatMessageHandler2should distinguish between "fallback due to error" and "user manually selected a different model"Suggested Fix
There are two approaches:
Approach A: Fix
handleSessionCreatedto not overwrite on manual selectionIn the session.created event handler, check if the user already has a pending model selection before overwriting. If
chat.messagealready processed the message and detected a manual model change (reset state),session.createdshould not overwrite that.Approach B: Fix
createChatMessageHandler2to respect user selectionWhen
activeModel !== originalModel:input.modelcontains the user's UI selectionA minimal fix would be in
createChatMessageHandler2: add a check that ifinput.modelmatchesstate.currentModeland differs fromstate.originalModel, the user intentionally chose this model — do not override.Additional Context
hasExplicitAgentModelOverridereturns false, causing a different code path that does not interact with session state)