@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
22
33import { prepareApiConversationMessage } from "../apiConversationHistory.js"
44import { providerIdentifiers } from "@roo-code/types/provider-identifiers"
5+ import type { ApiHandler } from "../../../api"
56
67describe ( "prepareApiConversationMessage" , ( ) => {
78 beforeEach ( ( ) => {
@@ -83,6 +84,40 @@ describe("prepareApiConversationMessage", () => {
8384 ] )
8485 } )
8586
87+ it . each ( [ "reasoning-1" , undefined ] ) ( "preserves encrypted reasoning alongside its visible text (id: %s)" , ( id ) => {
88+ const api = {
89+ createMessage : vi . fn < ApiHandler [ "createMessage" ] > ( ) ,
90+ getModel : vi . fn < ApiHandler [ "getModel" ] > ( ) ,
91+ countTokens : vi . fn < ApiHandler [ "countTokens" ] > ( ) ,
92+ getEncryptedContent : ( ) => ( { encrypted_content : "encrypted" , ...( id ? { id } : { } ) } ) ,
93+ }
94+ const result = prepareApiConversationMessage ( {
95+ message : {
96+ role : "assistant" ,
97+ content : [
98+ { type : "text" , text : "Reading files" } ,
99+ { type : "tool_use" , id : "call-1" , name : "read_file" , input : { path : "a.ts" } } ,
100+ ] ,
101+ } ,
102+ reasoning : "visible reasoning" ,
103+ api,
104+ apiConfiguration : { apiProvider : providerIdentifiers . openaiCodex } ,
105+ apiConversationHistory : [ ] ,
106+ } )
107+
108+ expect ( result . content ) . toEqual ( [
109+ {
110+ type : "reasoning" ,
111+ text : "visible reasoning" ,
112+ summary : [ ] ,
113+ encrypted_content : "encrypted" ,
114+ ...( id ? { id } : { } ) ,
115+ } ,
116+ { type : "text" , text : "Reading files" } ,
117+ { type : "tool_use" , id : "call-1" , name : "read_file" , input : { path : "a.ts" } } ,
118+ ] )
119+ } )
120+
86121 it ( "appends thought signatures for non-Anthropic protocols" , ( ) => {
87122 const result = prepareApiConversationMessage ( {
88123 message : { role : "assistant" , content : "answer" } ,
0 commit comments