feat(subagent): replace downgrade heuristic with 4-step model resolution chain#724
Merged
Merged
Conversation
…ion chain - Add SubagentConfig to ProfileConfig with optional model field - Thread subagent_model() through all call sites (ACP, async, interactive, MCP, autopilot, warden) - Replace downgrade_model_choice() with resolve_subagent_model() resolution chain: 1. Caller-supplied model override 2. Profile [subagent].model config 3. Built-in provider-specific defaults (new default_subagent_model() table) 4. Parent model inheritance - Add model parameter to DynamicSubagentRequest for per-call overrides - Add logging of resolved model with resolution step for observability - Update tests: config parsing/merge for subagent field, resolution priority tests
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.
Description
Replaces the hard-coded
downgrade_model_choice()heuristic with a configurable 4-step subagent model resolution chain.Changes Made
modelfield onSubagentConfig(both in CLI profile config and MCP server config), allowing per-profile subagent model overrides via[profiles.default.subagent] model = "...".resolve_subagent_model(): New resolution function with a clear priority chain:modelparameter onDynamicSubagentRequest, used verbatim when set[subagent].modelfrom the active profiledefault_subagent_model()lookup table (anthropic→haiku-4-5, openai→gpt-5-mini, gemini→2.0-flash, etc.)SubagentConfig.modelthreaded through all call sites: ACP server, async mode, interactive mode, MCP server, autopilot, warden testscaller_override,profile_config,builtin_default,parent_inherit) and task IDsubagentfieldRelated Issues
Replaces the brittle string-replacement downgrade logic (
opus→haiku,sonnet→haiku) with a maintainable lookup table and explicit configuration surface.Testing
cargo test -p stakpak-mcp-server, config tests)cargo clippy --all-targets -- -D warnings)cargo fmt --check)Breaking Changes
None — the new
modelparameter onDynamicSubagentRequestis optional and defaults to the existing behavior (provider-specific default → parent inheritance).