@@ -157,6 +157,39 @@ describe('Runner.run', () => {
157157 await expect ( run ( agent , 'fail' ) ) . rejects . toThrow ( 'No response found' ) ;
158158 } ) ;
159159
160+ it ( 'sets overridePromptModel when agent supplies a prompt and explicit model' , async ( ) => {
161+ class CapturingModel implements Model {
162+ lastRequest ?: ModelRequest ;
163+ async getResponse ( request : ModelRequest ) : Promise < ModelResponse > {
164+ this . lastRequest = request ;
165+ return {
166+ output : [ fakeModelMessage ( 'override' ) ] ,
167+ usage : new Usage ( ) ,
168+ } ;
169+ }
170+ async * getStreamedResponse (
171+ _request : ModelRequest ,
172+ ) : AsyncIterable < protocol . StreamEvent > {
173+ yield * [ ] ;
174+ throw new Error ( 'Not implemented' ) ;
175+ }
176+ }
177+
178+ const capturingModel = new CapturingModel ( ) ;
179+
180+ const agent = new Agent ( {
181+ name : 'Prompted' ,
182+ instructions : 'Use the prompt.' ,
183+ model : capturingModel ,
184+ prompt : { promptId : 'prompt_123' } ,
185+ } ) ;
186+
187+ await run ( agent , 'hello' ) ;
188+
189+ expect ( capturingModel . lastRequest ?. prompt ) . toBeDefined ( ) ;
190+ expect ( capturingModel . lastRequest ?. overridePromptModel ) . toBe ( true ) ;
191+ } ) ;
192+
160193 it ( 'emits agent_end lifecycle event for non-streaming agents' , async ( ) => {
161194 const agent = new Agent ( {
162195 name : 'TestAgent' ,
0 commit comments