@@ -12,6 +12,7 @@ import {
1212 modelKey ,
1313 resolveAllowedModelRef ,
1414 resolveConfiguredModelRef ,
15+ resolveSubagentConfiguredModelSelection ,
1516 resolveThinkingDefault ,
1617 resolveModelRefFromString ,
1718} from "./model-selection.js" ;
@@ -857,3 +858,48 @@ describe("normalizeModelSelection", () => {
857858 expect ( normalizeModelSelection ( 42 ) ) . toBeUndefined ( ) ;
858859 } ) ;
859860} ) ;
861+
862+ describe ( "resolveSubagentConfiguredModelSelection" , ( ) => {
863+ it ( "prefers the agent primary model over agents.defaults.subagents.model" , ( ) => {
864+ const cfg = {
865+ agents : {
866+ defaults : {
867+ model : { primary : "anthropic/claude-sonnet-4-6" } ,
868+ subagents : { model : "openai/gpt-5.4" } ,
869+ } ,
870+ list : [
871+ {
872+ id : "research" ,
873+ model : { primary : "anthropic/claude-opus-4-6" } ,
874+ } ,
875+ ] ,
876+ } ,
877+ } as OpenClawConfig ;
878+
879+ expect ( resolveSubagentConfiguredModelSelection ( { cfg, agentId : "research" } ) ) . toBe (
880+ "anthropic/claude-opus-4-6" ,
881+ ) ;
882+ } ) ;
883+
884+ it ( "still prefers agent subagents.model over the agent primary model" , ( ) => {
885+ const cfg = {
886+ agents : {
887+ defaults : {
888+ model : { primary : "anthropic/claude-sonnet-4-6" } ,
889+ subagents : { model : "openai/gpt-5.4" } ,
890+ } ,
891+ list : [
892+ {
893+ id : "research" ,
894+ model : { primary : "anthropic/claude-opus-4-6" } ,
895+ subagents : { model : "google/gemini-2.5-pro" } ,
896+ } ,
897+ ] ,
898+ } ,
899+ } as OpenClawConfig ;
900+
901+ expect ( resolveSubagentConfiguredModelSelection ( { cfg, agentId : "research" } ) ) . toBe (
902+ "google/gemini-2.5-pro" ,
903+ ) ;
904+ } ) ;
905+ } ) ;
0 commit comments