Repository navigation
feat(orchestration): support OpenCode worker model selection #22134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
user141514
wants to merge
1
commit into
stablyai:main
from
user141514:feat/opencode-worker-launch-preferences
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { getAgentSessionOptionCatalog } from './agent-session-option-catalog' | ||
| import { | ||
| removeOverriddenAgentSessionArgs, | ||
| resolveAgentSessionOptionLaunch | ||
| } from './agent-session-option-launch' | ||
|
|
||
| describe('OpenCode launch options', () => { | ||
| it('does not expose worker-only launch options as an interactive session catalog', () => { | ||
| expect(getAgentSessionOptionCatalog('opencode')).toBeNull() | ||
| }) | ||
|
|
||
| it('maps an opaque model id to the OpenCode --model flag', () => { | ||
| expect( | ||
| resolveAgentSessionOptionLaunch('opencode', { | ||
| model: 'zai-coding-plan/glm-5.3-flash' | ||
| }) | ||
| ).toEqual({ | ||
| args: ['--model', 'zai-coding-plan/glm-5.3-flash'], | ||
| appliedValues: { model: 'zai-coding-plan/glm-5.3-flash' } | ||
| }) | ||
| }) | ||
|
|
||
| it('removes a configured model flag before applying a per-launch model', () => { | ||
| expect( | ||
| removeOverriddenAgentSessionArgs('opencode', { model: 'zai-coding-plan/glm-5.3-flash' }, [ | ||
| '--model', | ||
| 'opencode/global-default', | ||
| '--log-level', | ||
| 'DEBUG' | ||
| ]) | ||
| ).toEqual(['--log-level', 'DEBUG']) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { hasFlag } from './agent-cli-flag-detection' | ||
| import { removeAgentArgOption } from './agent-session-option-agent-args' | ||
| import type { AgentSessionOptionCatalog } from './agent-session-option-catalog-types' | ||
|
|
||
| const MODEL_FLAGS = ['-m', '--model'] as const | ||
|
|
||
| // Why: worker-start needs launch serialization without exposing a new Native Chat option surface. | ||
| export const OPENCODE_LAUNCH_OPTION_CATALOG: AgentSessionOptionCatalog = { | ||
| supportsWorkerLaunchPreferences: true, | ||
| models: [], | ||
| modelApply: { | ||
| launchArgs: (value) => ['--model', String(value)], | ||
| agentArgsOverride: (tokens) => hasFlag(tokens, MODEL_FLAGS), | ||
| removeAgentArgs: (tokens) => removeAgentArgOption(tokens, MODEL_FLAGS) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAgentSessionOptionLaunchCatalogspecial-cases only'opencode', soworker-start --agent opencode2 --model …still throws "does not support launch-time model selection" even thoughopencode2is the same OpenCode family whose config note says it uses the same flags. Was scoping toopencodedeliberate here, or shouldopencode2(and possiblymimo-code) route to the same launch catalog? Not a regression — those agents were rejected before this PR too.