@@ -39,7 +39,9 @@ describe("prepareApiConversationMessage", () => {
3939 const result = prepareApiConversationMessage ( {
4040 message : { role : "assistant" , content : "answer" } ,
4141 reasoning : "visible reasoning" ,
42- api : { } as any ,
42+ api : {
43+ getModel : ( ) => ( { info : { } } ) ,
44+ } as any ,
4345 apiConfiguration : { apiProvider : "openrouter" , openRouterModelId : "openai/gpt-4" } as any ,
4446 apiConversationHistory : [ ] ,
4547 } ) as any
@@ -50,11 +52,31 @@ describe("prepareApiConversationMessage", () => {
5052 ] )
5153 } )
5254
55+ it ( "stores reasoning_content for OpenAI-format models that need reasoning replay" , ( ) => {
56+ const result = prepareApiConversationMessage ( {
57+ message : { role : "assistant" , content : "answer" } ,
58+ reasoning : "visible reasoning" ,
59+ api : {
60+ getModel : ( ) => ( { info : { preserveReasoning : true } } ) ,
61+ } as any ,
62+ apiConfiguration : { apiProvider : "deepseek" , apiModelId : "deepseek-v4-pro" } as any ,
63+ apiConversationHistory : [ ] ,
64+ } ) as any
65+
66+ expect ( result . reasoning_content ) . toBe ( "visible reasoning" )
67+ expect ( result . content ) . toEqual ( [
68+ { type : "reasoning" , text : "visible reasoning" , summary : [ ] } ,
69+ { type : "text" , text : "answer" } ,
70+ ] )
71+ } )
72+
5373 it ( "falls back to generic reasoning blocks for Anthropic messages without thought signatures" , ( ) => {
5474 const result = prepareApiConversationMessage ( {
5575 message : { role : "assistant" , content : "answer" } ,
5676 reasoning : "private reasoning" ,
57- api : { } as any ,
77+ api : {
78+ getModel : ( ) => ( { info : { } } ) ,
79+ } as any ,
5880 apiConfiguration : { apiProvider : "anthropic" , apiModelId : "claude-3-5-sonnet" } as any ,
5981 apiConversationHistory : [ ] ,
6082 } ) as any
@@ -70,6 +92,7 @@ describe("prepareApiConversationMessage", () => {
7092 const result = prepareApiConversationMessage ( {
7193 message : { role : "assistant" , content : [ { type : "text" , text : "answer" } ] } ,
7294 api : {
95+ getModel : ( ) => ( { info : { } } ) ,
7396 getEncryptedContent : ( ) => ( { encrypted_content : "encrypted" , id : "reasoning-1" } ) ,
7497 } as any ,
7598 apiConfiguration : { apiProvider : "openrouter" , openRouterModelId : "openai/gpt-4" } as any ,
@@ -86,6 +109,7 @@ describe("prepareApiConversationMessage", () => {
86109 const result = prepareApiConversationMessage ( {
87110 message : { role : "assistant" , content : "answer" } ,
88111 api : {
112+ getModel : ( ) => ( { info : { } } ) ,
89113 getThoughtSignature : ( ) => "signature-1" ,
90114 getReasoningDetails : ( ) => [ { type : "reasoning" , text : "detail" } ] ,
91115 } as any ,
0 commit comments