Skip to content

fix: preserve explicit model selection in command subtasks#18752

Open
Haohao-end wants to merge 3 commits intoanomalyco:devfrom
Haohao-end:fix/18615-explicit-model-over-agent
Open

fix: preserve explicit model selection in command subtasks#18752
Haohao-end wants to merge 3 commits intoanomalyco:devfrom
Haohao-end:fix/18615-explicit-model-over-agent

Conversation

@Haohao-end
Copy link
Copy Markdown

@Haohao-end Haohao-end commented Mar 23, 2026

Issue for this PR

Closes #18615

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes model precedence in the command/subtask delegation path.

The bug was that an explicit model input could still be overridden by an agent-configured fallback model when resolving a command/subtask request.

I changed the precedence in packages/opencode/src/session/prompt.ts so that it is now:

  1. explicitly provided model
  2. command-configured model
  3. command agent fallback model
  4. previous / inherited model fallback

Why this works:

  • the explicit model is now preserved when a command/subtask is created
  • existing fallback behavior is still preserved when no explicit model is provided

How did you verify your code works?

I tested locally with:

  • cd packages/opencode && bun test test/session/prompt.test.ts --timeout 30000
  • cd packages/opencode && bun run typecheck

I also added focused regression coverage to verify that explicit model selection is preserved in the command/subtask path.

Screenshots / recordings

N/A (not a UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

PR #17788: "fix: prioritize CLI --model argument over command markdown model"

This PR is related because both deal with model precedence and ensuring explicit model selections aren't overridden by fallback models. However, PR #17788 focuses on the CLI --model argument path, while PR #18752 addresses the subtask/command delegation path.

@Haohao-end Haohao-end changed the title fix: preserve explicit model selection for subtask commands fix: preserve explicit model selection in command subtasks Mar 23, 2026
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] Model parameter ignored when launching subagent with agent name

1 participant