fix(query): preserve explicit model selection#31
Open
BunsDev wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the query model-selection flow to ensure that when a caller explicitly selects a model/provider (e.g., via CLI flags), that choice is preserved and not silently overridden by managed_agents.manager_model at query runtime—reducing the risk of prompts being routed to an unexpected provider.
Changes:
- Add
preserve_selected_model: booltoQueryConfig(defaultfalse) to record explicit caller selection intent. - Centralize model selection in
selected_model_for_query(&QueryConfig) -> String, applyingmanaged_agents.manager_modelonly whenpreserve_selected_model == false. - Wire the flag from the CLI (
--model/--provider) and updateAgentTool/ tests to initialize the new field.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src-rust/crates/query/src/lib.rs |
Adds the new config flag, centralizes model selection logic, and adds unit tests for override vs preservation behavior. |
src-rust/crates/query/src/agent_tool.rs |
Updates QueryConfig construction to initialize preserve_selected_model for agent tool invocations. |
src-rust/crates/cli/src/main.rs |
Sets preserve_selected_model when --model or --provider is explicitly provided. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
managed_agents.manager_modelfrom silently replacing an explicit caller-selected model/provider (e.g.--model) at query runtime, which could route private prompts to an unexpected provider.Description
preserve_selected_model: booltoQueryConfig(defaultfalse) to record when a caller explicitly selected model/provider.selected_model_for_query(cfg: &QueryConfig) -> Stringto centralize selection logic and return the manager model only whenpreserve_selected_modelisfalse.run_query_loopwithselected_model_for_queryand makeeffective_modelderived from it.query_config.preserve_selected_model = cli.model.is_some() || cli.provider.is_some()in the CLI, and ensure sub-agentQueryConfiginstances set it tofalse.agent_tooland other call sites to initialize the new flag.Testing
cargo test --package claurst-query test_explicit_model_selection_blocks_managed_agent_overrideand it passed.cargo test --package claurst-query test_managed_agent_manager_model_overrides_by_defaultand it passed.cargo check --package claurst-queryand it succeeded.cargo check --workspacewas attempted but blocked by a missing system dependency (alsa.pc/ ALSA pkg-config) in the environment, so workspace-wide check could not complete here.Codex Task