@@ -361,6 +361,8 @@ export class SessionSubagentHost {
361361 // All subagent lifecycle events carry the launching tool call id so
362362 // consumers can correlate them to a workflow and drop stale events.
363363 parentToolCallId : event . task . parentToolCallId ,
364+ workflowRunId : event . task . workflowRunId ,
365+ workflowName : event . task . workflowName ,
364366 reason : event . reason ,
365367 } ) ;
366368 }
@@ -437,16 +439,28 @@ export class SessionSubagentHost {
437439 * SingleModelProvider) falls back to the parent's model instead of failing at
438440 * generate time. fastMode stays a straight inherit: it is a preference the
439441 * provider layer already drops when the active model cannot serve it.
442+ *
443+ * A `model:` deny rule is re-checked here as well — approval only sees a
444+ * model that was in the tool arguments, so a profile-sourced override (or a
445+ * resume/retry re-resolution) would otherwise ride past `Agent(model:x)` /
446+ * `DynamicWorkflow(model:x)`. Every override lands in this method, making it
447+ * the one containment point; a denied override falls back to the parent's
448+ * model rather than failing the spawn.
440449 */
441450 private childModelConfig (
442451 parent : Agent ,
443452 child : Agent ,
444453 profile : ResolvedAgentProfile | undefined ,
445- options : Pick < RunSubagentOptions , 'modelAlias' | 'thinkingLevel' > ,
454+ options : Pick < RunSubagentOptions , 'modelAlias' | 'thinkingLevel' | 'workflowRunId' > ,
446455 ) : { modelAlias : string | undefined ; thinkingLevel : string | undefined ; fastMode : boolean } {
447456 const requested = options . modelAlias ?? profile ?. model ;
448457 const modelAlias =
449- requested !== undefined && child . config . canResolveModel ( requested )
458+ requested !== undefined &&
459+ child . config . canResolveModel ( requested ) &&
460+ ! parent . permission . deniesModelOverride (
461+ options . workflowRunId === undefined ? 'Agent' : 'DynamicWorkflow' ,
462+ requested ,
463+ )
450464 ? requested
451465 : parent . config . modelAlias ;
452466 return {
@@ -562,6 +576,7 @@ export class SessionSubagentHost {
562576 subagentId : childId ,
563577 parentToolCallId : options . parentToolCallId ,
564578 workflowRunId : options . workflowRunId ,
579+ workflowName : options . workflowName ,
565580 resultSummary : result ,
566581 usage,
567582 contextTokens : child . context . tokenCount ,
@@ -712,6 +727,7 @@ export class SessionSubagentHost {
712727 subagentId : childId ,
713728 parentToolCallId : options . parentToolCallId ,
714729 workflowRunId : options . workflowRunId ,
730+ workflowName : options . workflowName ,
715731 } ) ;
716732 }
717733
@@ -727,6 +743,7 @@ export class SessionSubagentHost {
727743 subagentId : childId ,
728744 parentToolCallId : options . parentToolCallId ,
729745 workflowRunId : options . workflowRunId ,
746+ workflowName : options . workflowName ,
730747 error : error instanceof Error ? error . message : String ( error ) ,
731748 } ) ;
732749 }
0 commit comments