Skip to content

Add opencode model variant customization - #739

Open
nhojb wants to merge 5 commits into
xenodium:mainfrom
nhojb:f/opencode-model-variant
Open

Add opencode model variant customization#739
nhojb wants to merge 5 commits into
xenodium:mainfrom
nhojb:f/opencode-model-variant

Conversation

@nhojb

@nhojb nhojb commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Opencode does not currently support setting a persistent model variant via the opencode config json - or at least it does not work when running via acp. So this PR adds:

  1. Support for setting the default-thought-level-id via agent-shell-make-agent-config
  2. A new agent-shell-opencode-default-model-variant defcustom

Note: if the variant is not supported by the current model, then the user will see an error when loading the session

Screenshot 2026-07-29 at 14 07 13 Screenshot 2026-07-29 at 13 52 40

Checklist

  • I agree to communicate (PR description and comments) with the author myself (not AI-generated).
  • I've reviewed all code in PR myself and will vouch for its quality.
  • I've read and followed the Contributing guidelines.
  • I've filed a feature request/discussion for a new feature.
  • I'm making visual changes, so I'm including screenshots so you can view and discuss.
  • I've added tests where applicable.
  • I've updated documentation where necessary.
  • I've run M-x checkdoc and M-x byte-compile-file.

@xenodium

xenodium commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR!

I'm wondering if you'd be keen to steer the PR towards a more generic mechanism? Instead of adding agent-shell-opencode-default-model-variant, we add something like:

(defcustom agent-shell-opencode-default-config-options
  '(("model"         . "anthropic/claude-opus-4-5")
    ("thought_level" . "high")
    ("mode"          . "plan"))
  "Default OpenCode config options, applied at session start.
Keys are config-option categories advertised by the agent; see
the \"Available config options\" section in your shell."
  :type '(alist :key-type string :value-type string))

I know we haven't done this before in project, but it would enable us to set precedence for moving towards a more scalable mechanism for users to set whatever option is supported by their agent without requiring additional agent-shell changes.

To support this path, I've just submitted 95c700a which enables users to know exactly what is and isn't supported by their agents.

image

@nhojb
nhojb force-pushed the f/opencode-model-variant branch from cab379d to e2c31cf Compare August 3, 2026 14:23
@nhojb

nhojb commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

I'm wondering if you'd be keen to steer the PR towards a more generic mechanism?

Sounds good to me. I will also mark the old agent-shell-opencode-default-model-id as deprecated and fallback if the new config does not exist.

christian-smith pushed a commit to christian-smith/agent-shell that referenced this pull request Aug 4, 2026
@nhojb
nhojb force-pushed the f/opencode-model-variant branch 2 times, most recently from c40dcff to 101bbe6 Compare August 17, 2026 10:26
@nhojb
nhojb force-pushed the f/opencode-model-variant branch from 101bbe6 to 7e4f912 Compare August 25, 2026 11:45
nhojb and others added 3 commits August 25, 2026 13:27
agent-shell--config-option-set-model-id and its mode twin fall back to
session/set_model and session/set_mode for agents advertising no config
options, so default-config-options routes through them rather than
always sending session/set_config_option.

Dispatch is on the entry's key, not the resolved option's category:
Cline tags both its provider and model options with category "model",
so routing on category would hand a provider entry to the model setter,
which resolves category "model" back to the model option.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@nhojb

nhojb commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Done. Apologies for the delay.

You can now set opencode options like this:

(setq agent-shell-opencode-default-config-options
   '(("model" . "openrouter/moonshotai/kimi-k3")
     ("effort" . "high")))

Note: I did not remove default-model-id or default-session-id from agent-shell-make-agent-config even though they can now be set via default-config-options. That could be done in a follow-up, but touches most of the other agents.

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.

2 participants