@@ -83,7 +83,7 @@ describe("subagent traits", () => {
8383 resolveSubagentTraits ( {
8484 subagent : { ...subagent , modelSelection : undefined } ,
8585 provider,
86- childThread : { modelSelection : selection } ,
86+ childThread : { providerInstanceId : instanceId , modelSelection : selection } ,
8787 } ) ,
8888 ) . toBe ( "High · Fast" ) ;
8989 } ) ;
@@ -93,7 +93,7 @@ describe("subagent traits", () => {
9393 resolveSubagentTraits ( {
9494 subagent : { ...subagent , origin : "provider_native" , modelSelection : undefined } ,
9595 provider,
96- childThread : { modelSelection : selection } ,
96+ childThread : { providerInstanceId : instanceId , modelSelection : selection } ,
9797 } ) ,
9898 ) . toBe ( "" ) ;
9999 } ) ;
@@ -120,6 +120,7 @@ describe("subagent traits", () => {
120120 subagent,
121121 provider,
122122 childThread : {
123+ providerInstanceId : instanceId ,
123124 modelSelection : { ...selection , options : [ { id : "reasoningEffort" , value : "low" } ] } ,
124125 } ,
125126 } ) ,
@@ -178,4 +179,73 @@ describe("subagent traits", () => {
178179 } ) ,
179180 ) . toBe ( label ) ;
180181 } ) ;
182+
183+ it ( "uses a validated app-owned child's provider for cross-provider workflow traits" , ( ) => {
184+ const childInstanceId = ProviderInstanceId . make ( "claude" ) ;
185+ const childSelection : ModelSelection = {
186+ instanceId : childInstanceId ,
187+ model : "claude-test" ,
188+ options : [
189+ { id : "effort" , value : "max" } ,
190+ { id : "fastMode" , value : true } ,
191+ ] ,
192+ } ;
193+ const childProvider = {
194+ instanceId : childInstanceId ,
195+ driver : ProviderDriverKind . make ( "claudeAgent" ) ,
196+ models : [
197+ {
198+ slug : "claude-test" ,
199+ name : "Claude Test" ,
200+ isCustom : false ,
201+ capabilities : {
202+ optionDescriptors : [
203+ {
204+ id : "effort" ,
205+ label : "Effort" ,
206+ type : "select" as const ,
207+ options : [ { id : "max" , label : "Max" } ] ,
208+ } ,
209+ { id : "fastMode" , label : "Fast" , type : "boolean" as const } ,
210+ ] ,
211+ } ,
212+ } ,
213+ ] ,
214+ } ;
215+ const input = {
216+ subagent : { ...subagent , model : "Claude Test" , modelSelection : undefined } ,
217+ provider,
218+ childProvider,
219+ childThread : { providerInstanceId : childInstanceId , modelSelection : childSelection } ,
220+ } ;
221+ expect ( resolveSubagentTraits ( input ) ) . toBe ( "Max · Fast" ) ;
222+ expect ( resolveSubagentTraits ( { ...input , subagent } ) ) . toBe ( "High · Fast" ) ;
223+ expect (
224+ resolveSubagentTraits ( {
225+ ...input ,
226+ subagent : { ...input . subagent , origin : "provider_native" } ,
227+ } ) ,
228+ ) . toBe ( "" ) ;
229+ expect ( resolveSubagentTraits ( { ...input , childThread : undefined } ) ) . toBe ( "" ) ;
230+ expect ( resolveSubagentTraits ( { ...input , childProvider : undefined } ) ) . toBe ( "" ) ;
231+ expect (
232+ resolveSubagentTraits ( {
233+ ...input ,
234+ childThread : { ...input . childThread , providerInstanceId : instanceId } ,
235+ } ) ,
236+ ) . toBe ( "" ) ;
237+ expect (
238+ resolveSubagentTraits ( { ...input , childProvider : { ...childProvider , instanceId } } ) ,
239+ ) . toBe ( "" ) ;
240+ expect (
241+ resolveSubagentTraits ( { ...input , subagent : { ...input . subagent , model : "another-model" } } ) ,
242+ ) . toBe ( "" ) ;
243+ expect (
244+ resolveSubagentTraits ( {
245+ subagent : { ...subagent , modelSelection : undefined } ,
246+ provider,
247+ childThread : { providerInstanceId : childInstanceId , modelSelection : selection } ,
248+ } ) ,
249+ ) . toBe ( "" ) ;
250+ } ) ;
181251} ) ;
0 commit comments