Skip to content

fix(plugin): persist selected model only for main session#2798

Merged
code-yeongyu merged 1 commit intodevfrom
fix/2353-model-selection-v2
Mar 24, 2026
Merged

fix(plugin): persist selected model only for main session#2798
code-yeongyu merged 1 commit intodevfrom
fix/2353-model-selection-v2

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 24, 2026

Summary

  • Reuse the stored model only for subsequent messages in the true main session when the UI does not send a model.
  • Keep first-message behavior unchanged, preserve explicit agent model overrides, and block any leakage into subagent sessions.
  • Add regressions for main-session reuse, first-message safety, subagent isolation, explicit override precedence, and mid-conversation model switching.

Verification

  • bun test src/plugin/chat-message.test.ts src/plugin-handlers/agent-config-handler.test.ts src/plugin-handlers/config-handler.test.ts
  • bun run typecheck
  • bun run build

Context


Summary by cubic

Persist and reuse the selected model only for the true main session, and only on follow-up messages when the UI sends no model. Keeps first-message behavior, agent model overrides, and subagent isolation intact (addresses #2353).

  • Bug Fixes
    • Reuse stored model only when: main session, not first message, UI sent no model, and no explicit agent override.
    • Never reuse for subagent sessions.
    • Do not override explicit agent models; they take precedence.
    • Respect mid-conversation model switches and update the stored model. Added regression tests for all cases.

Written for commit 7fa2417. Summary will update on new commits.

Reuse the stored model only for subsequent main-session messages when the UI provides no model, while preserving first-message behavior, explicit overrides, and subagent isolation.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 2/5

  • There is a high-confidence functional issue in src/plugin/chat-message.ts: looking up pluginConfig.agents with the raw agent name (instead of getAgentConfigKey(agent)) can cause the wrong agent config to be applied at runtime.
  • The same code path also ignores overrides from the non-deprecated category field, so configured behavior may not match user/admin expectations even when valid overrides exist.
  • Given the 8/10 severity and direct behavior impact in message handling/config resolution, this is a high-risk merge until the lookup and override logic are aligned.
  • Pay close attention to src/plugin/chat-message.ts - agent key mapping and category-based override resolution are likely to regress configuration behavior.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/plugin/chat-message.ts">

<violation number="1" location="src/plugin/chat-message.ts:40">
P1: The raw agent name must be mapped via `getAgentConfigKey(agent)` before looking it up in `pluginConfig.agents`. Additionally, the function misses overrides defined via the non-deprecated `category` field (`configuredAgent?.category`).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

})
}

function hasExplicitAgentModelOverride(
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The raw agent name must be mapped via getAgentConfigKey(agent) before looking it up in pluginConfig.agents. Additionally, the function misses overrides defined via the non-deprecated category field (configuredAgent?.category).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/plugin/chat-message.ts, line 40:

<comment>The raw agent name must be mapped via `getAgentConfigKey(agent)` before looking it up in `pluginConfig.agents`. Additionally, the function misses overrides defined via the non-deprecated `category` field (`configuredAgent?.category`).</comment>

<file context>
@@ -35,6 +37,53 @@ function isStartWorkHookOutput(value: unknown): value is StartWorkHookOutput {
   })
 }
 
+function hasExplicitAgentModelOverride(
+  agent: string | undefined,
+  pluginConfig: OhMyOpenCodeConfig
</file context>
Fix with Cubic

@code-yeongyu code-yeongyu merged commit cea8769 into dev Mar 24, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/2353-model-selection-v2 branch March 24, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Every time I send a message, the model always resets to "Claude Opus 4.6" in windows desktop

1 participant