Skip to content

fix(plan): resolve model from agent config in plan tools#18163

Open
filipeandre wants to merge 1 commit intoanomalyco:devfrom
filipeandre:fix/plan-agent-model
Open

fix(plan): resolve model from agent config in plan tools#18163
filipeandre wants to merge 1 commit intoanomalyco:devfrom
filipeandre:fix/plan-agent-model

Conversation

@filipeandre
Copy link

@filipeandre filipeandre commented Mar 18, 2026

Issue for this PR

Closes #9296

Type of change

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

What does this PR do?

When a user configures a specific model for the build or plan agent (e.g. agent.build.model = "openai/gpt-4o"), the plan tools were ignoring it. Both PlanExitTool and PlanEnterTool were always falling back to the last model seen in the session history via getLastModel, so the build agent would inherit the plan agent's model instead of its own configured one.

This PR adds a resolveModel helper that calls Agent.get(agentName) first and uses the configured model if present, only falling back to the last session model when none is set. PlanExitTool resolves for the build agent and PlanEnterTool for the plan agent.

How did you verify your code works?

Added two tests in packages/opencode/test/tool/plan.test.ts:

  • One verifies that when agent.build.model is configured, the message written by PlanExitTool uses that model.
  • One verifies that when no model is configured, it falls back to the last session model.

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 github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 18, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Mar 18, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@filipeandre filipeandre force-pushed the fix/plan-agent-model branch from a443499 to fb47bf8 Compare March 18, 2026 23:53
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.

Experimental plan mode handover -> build uses plan agent's model

1 participant