@@ -2163,6 +2163,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
21632163 // so session.post reports outcome="cancelled" instead of "error".
21642164 let cancelled = false
21652165 let cancelReason : string | undefined
2166+ let lastSystemPrompt : string [ ] | undefined = undefined
21662167
21672168 // Fires session.post exactly once via Effect.onExit on the body below.
21682169 // Without this wrapper any yielded failure inside the while loop (provider
@@ -2208,6 +2209,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
22082209 finalText : finalAsst ? assistantFinalText ( finalAsst , finalParts ) : undefined ,
22092210 assistantMessageID : finalAsst ?. id ,
22102211 trajectory : serializeTrajectoryMessages ( sliceMsgs ) ,
2212+ systemPrompt : lastSystemPrompt ,
22112213 } ,
22122214 { } ,
22132215 )
@@ -3372,6 +3374,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
33723374 )
33733375 const ownNewModelMsgs = yield * MessageV2 . toModelMessagesEffect ( ownNew , model )
33743376 const prebuiltSystem = forkCtx . system
3377+ lastSystemPrompt = prebuiltSystem
33753378 const modelMsgs : ModelMessage [ ] = [ ...forkCtx . inheritedMessages , ...ownNewModelMsgs ]
33763379 // additions is empty for fork agents: system is taken verbatim from
33773380 // forkCtx.system. Passed as `system` to handle.process for logging/replay.
@@ -3413,6 +3416,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
34133416 finish : handle . message . finish ,
34143417 error : preQuery . cancelReason ,
34153418 trajectory : trajectoryForStep ( msgs , handle . message ) ,
3419+ systemPrompt : lastSystemPrompt ,
34163420 } ,
34173421 { } ,
34183422 )
@@ -3465,6 +3469,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
34653469 : sessionErrorText ( handle . message . error ) ,
34663470 finalText : assistantFinalText ( handle . message , MessageV2 . parts ( handle . message . id ) ) ,
34673471 trajectory : trajectoryForStep ( msgs , handle . message ) ,
3472+ systemPrompt : lastSystemPrompt ,
34683473 } ,
34693474 { } ,
34703475 )
@@ -3598,6 +3603,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
35983603 Effect . provideService ( LLM . Service , llm ) ,
35993604 Effect . provideService ( ToolRegistry . Service , registry ) ,
36003605 )
3606+ lastSystemPrompt = prebuiltSystem
36013607 const maxModeCfg = ( yield * config . get ( ) ) . experimental ?. maxMode
36023608 const useMaxMode =
36033609 agent . name === MaxMode . MAX_MODE_AGENT && maxModeCfg !== undefined && format . type !== "json_schema"
@@ -3651,6 +3657,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
36513657 finish : handle . message . finish ,
36523658 error : preQuery . cancelReason ,
36533659 trajectory : trajectoryForStep ( msgs , handle . message ) ,
3660+ systemPrompt : lastSystemPrompt ,
36543661 } ,
36553662 { } ,
36563663 )
@@ -3688,6 +3695,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
36883695 : sessionErrorText ( handle . message . error ) ,
36893696 finalText : assistantFinalText ( handle . message , MessageV2 . parts ( handle . message . id ) ) ,
36903697 trajectory : trajectoryForStep ( msgs , handle . message ) ,
3698+ systemPrompt : lastSystemPrompt ,
36913699 } ,
36923700 { } ,
36933701 )
0 commit comments