@@ -1641,27 +1641,29 @@ export type ToStreamTextOptionsOptions = {
16411641 */
16421642function toStreamTextOptions ( options ?: ToStreamTextOptionsOptions ) : Record < string , unknown > {
16431643 const prompt = locals . get ( chatPromptKey ) ;
1644- if ( ! prompt ) return { } ;
1644+ const result : Record < string , unknown > = { } ;
16451645
1646- const result : Record < string , unknown > = {
1647- system : prompt . text ,
1648- } ;
1646+ // Prompt-related options (only if chat.prompt.set() was called)
1647+ if ( prompt ) {
1648+ result . system = prompt . text ;
16491649
1650- // Resolve model via registry if both are present
1651- if ( options ?. registry && prompt . model ) {
1652- result . model = options . registry . languageModel ( prompt . model ) ;
1653- }
1650+ // Resolve model via registry if both are present
1651+ if ( options ?. registry && prompt . model ) {
1652+ result . model = options . registry . languageModel ( prompt . model ) ;
1653+ }
16541654
1655- // Spread config (temperature, maxTokens, etc.)
1656- if ( prompt . config ) {
1657- Object . assign ( result , prompt . config ) ;
1658- }
1655+ // Spread config (temperature, maxTokens, etc.)
1656+ if ( prompt . config ) {
1657+ Object . assign ( result , prompt . config ) ;
1658+ }
16591659
1660- // Add telemetry (forward additional metadata from caller)
1661- const telemetry = prompt . toAISDKTelemetry ( options ?. telemetry ) ;
1662- Object . assign ( result , telemetry ) ;
1660+ // Add telemetry (forward additional metadata from caller)
1661+ const telemetry = prompt . toAISDKTelemetry ( options ?. telemetry ) ;
1662+ Object . assign ( result , telemetry ) ;
1663+ }
16631664
16641665 // Auto-inject prepareStep for compaction, pending messages, and background context injection.
1666+ // This runs regardless of whether a prompt is set — these features are independent.
16651667 const taskCompaction = locals . get ( chatAgentCompactionKey ) ;
16661668 const taskPendingMessages = locals . get ( chatPendingMessagesKey ) ;
16671669
0 commit comments