@@ -515,6 +515,37 @@ export namespace SessionPrompt {
515515 } )
516516 }
517517
518+ const messages = [
519+ ...system . map (
520+ ( x ) : ModelMessage => ( {
521+ role : "system" ,
522+ content : x ,
523+ } ) ,
524+ ) ,
525+ ...MessageV2 . toModelMessage (
526+ msgs . filter ( ( m ) => {
527+ if ( m . info . role !== "assistant" || m . info . error === undefined ) {
528+ return true
529+ }
530+ if (
531+ MessageV2 . AbortedError . isInstance ( m . info . error ) &&
532+ m . parts . some ( ( part ) => part . type !== "step-start" && part . type !== "reasoning" )
533+ ) {
534+ return true
535+ }
536+
537+ return false
538+ } ) ,
539+ ) ,
540+ ...( isLastStep
541+ ? [
542+ {
543+ role : "assistant" as const ,
544+ content : MAX_STEPS ,
545+ } ,
546+ ]
547+ : [ ] ) ,
548+ ]
518549 const result = await processor . process ( {
519550 onError ( error ) {
520551 log . error ( "stream error" , {
@@ -562,42 +593,12 @@ export namespace SessionPrompt {
562593 OUTPUT_TOKEN_MAX ,
563594 ) ,
564595 abortSignal : abort ,
565- providerOptions : ProviderTransform . providerOptions ( model , params . options ) ,
596+ providerOptions : ProviderTransform . providerOptions ( model , params . options , messages ) ,
566597 stopWhen : stepCountIs ( 1 ) ,
567598 temperature : params . temperature ,
568599 topP : params . topP ,
569600 toolChoice : isLastStep ? "none" : undefined ,
570- messages : [
571- ...system . map (
572- ( x ) : ModelMessage => ( {
573- role : "system" ,
574- content : x ,
575- } ) ,
576- ) ,
577- ...MessageV2 . toModelMessage (
578- msgs . filter ( ( m ) => {
579- if ( m . info . role !== "assistant" || m . info . error === undefined ) {
580- return true
581- }
582- if (
583- MessageV2 . AbortedError . isInstance ( m . info . error ) &&
584- m . parts . some ( ( part ) => part . type !== "step-start" && part . type !== "reasoning" )
585- ) {
586- return true
587- }
588-
589- return false
590- } ) ,
591- ) ,
592- ...( isLastStep
593- ? [
594- {
595- role : "assistant" as const ,
596- content : MAX_STEPS ,
597- } ,
598- ]
599- : [ ] ) ,
600- ] ,
601+ messages,
601602 tools : model . capabilities . toolcall === false ? undefined : tools ,
602603 model : wrapLanguageModel ( {
603604 model : language ,
@@ -1464,7 +1465,7 @@ export namespace SessionPrompt {
14641465 await generateText ( {
14651466 // use higher # for reasoning models since reasoning tokens eat up a lot of the budget
14661467 maxOutputTokens : small . capabilities . reasoning ? 3000 : 20 ,
1467- providerOptions : ProviderTransform . providerOptions ( small , options ) ,
1468+ providerOptions : ProviderTransform . providerOptions ( small , options , [ ] ) ,
14681469 messages : [
14691470 ...SystemPrompt . title ( small . providerID ) . map (
14701471 ( x ) : ModelMessage => ( {
0 commit comments