@@ -811,7 +811,7 @@ export class AgentOSOrchestrator {
811811 ) ;
812812 }
813813 break ;
814- case GMIOutputChunkType . ERROR :
814+ case GMIOutputChunkType . ERROR : {
815815 const errDetails = gmiChunk . errorDetails || { message : gmiChunk . content } ;
816816 await this . pushErrorChunk (
817817 agentOSStreamId , personaId , gmiInstanceIdForChunks ,
@@ -825,6 +825,7 @@ export class AgentOSOrchestrator {
825825 await this . dependencies . streamingManager . closeStream ( agentOSStreamId , `GMI stream error: ${ errDetails . message || String ( gmiChunk . content ) } ` ) ;
826826 }
827827 break ;
828+ }
828829 case GMIOutputChunkType . FINAL_RESPONSE_MARKER :
829830 // This chunk signals the end of GMI's streaming.
830831 // The actual final content should have been accumulated or is in this chunk's content/metadata.
@@ -834,24 +835,24 @@ export class AgentOSOrchestrator {
834835 // For now, if GMI explicitly sends this, we ensure the stream is marked for closure.
835836 // The main _processTurnInternal loop will handle the comprehensive AgentOSFinalResponseChunk.
836837 if ( gmiChunk . isFinal ) { // This marker SHOULD imply isFinal=true
837- if ( this . config . enableConversationalPersistence && conversationContext ) {
838- await this . dependencies . conversationManager . saveConversation ( conversationContext ) ;
839- }
840- // This is a simplified final response based *only* on this marker chunk.
841- // A more robust solution accumulates all data through the turn.
842- await this . pushChunkToStream (
843- agentOSStreamId , AgentOSResponseChunkType . FINAL_RESPONSE ,
844- gmiInstanceIdForChunks , personaId , true ,
845- {
846- finalResponseText : typeof gmiChunk . content === 'string' ? gmiChunk . content : "Processing complete." ,
847- // other fields like usage, trace would need to be on the FINAL_RESPONSE_MARKER content
848- // or aggregated throughout the turn.
849- updatedConversationContext : conversationContext . toJSON ( ) ,
850- activePersonaDetails : snapshotPersonaDetails ( gmi . getPersona ?.( ) ) ,
851- }
852- ) ;
853- this . activeStreamContexts . delete ( agentOSStreamId ) ;
854- await this . dependencies . streamingManager . closeStream ( agentOSStreamId , "GMI processing complete (final marker)." ) ;
838+ if ( this . config . enableConversationalPersistence && conversationContext ) {
839+ await this . dependencies . conversationManager . saveConversation ( conversationContext ) ;
840+ }
841+ // This is a simplified final response based *only* on this marker chunk.
842+ // A more robust solution accumulates all data through the turn.
843+ await this . pushChunkToStream (
844+ agentOSStreamId , AgentOSResponseChunkType . FINAL_RESPONSE ,
845+ gmiInstanceIdForChunks , personaId , true ,
846+ {
847+ finalResponseText : typeof gmiChunk . content === 'string' ? gmiChunk . content : "Processing complete." ,
848+ // other fields like usage, trace would need to be on the FINAL_RESPONSE_MARKER content
849+ // or aggregated throughout the turn.
850+ updatedConversationContext : conversationContext . toJSON ( ) ,
851+ activePersonaDetails : snapshotPersonaDetails ( gmi . getPersona ?.( ) ) ,
852+ }
853+ ) ;
854+ this . activeStreamContexts . delete ( agentOSStreamId ) ;
855+ await this . dependencies . streamingManager . closeStream ( agentOSStreamId , "GMI processing complete (final marker)." ) ;
855856 }
856857 break ;
857858 case GMIOutputChunkType . USAGE_UPDATE :
0 commit comments