@@ -2139,6 +2139,47 @@ describe("createOllamaStreamFn streaming events", () => {
21392139 ) ;
21402140 } ) ;
21412141
2142+ it ( "does not re-sanitize visible Kimi stream output before done" , async ( ) => {
2143+ const visibleAnswer =
2144+ "This visible answer is intentionally long enough to look like a reasoning prefix if it is sanitized a second time. ️ keep this marker visible." ;
2145+ await withMockNdjsonFetch (
2146+ [
2147+ JSON . stringify ( {
2148+ model : "kimi-k2.6:cloud" ,
2149+ created_at : "t" ,
2150+ message : {
2151+ role : "assistant" ,
2152+ content :
2153+ "I should think privately and not leak this planning text in the answer. I need to keep deciding what to say next. ️" ,
2154+ } ,
2155+ done : false ,
2156+ } ) ,
2157+ JSON . stringify ( {
2158+ model : "kimi-k2.6:cloud" ,
2159+ created_at : "t" ,
2160+ message : { role : "assistant" , content : visibleAnswer } ,
2161+ done : false ,
2162+ } ) ,
2163+ '{"model":"kimi-k2.6:cloud","created_at":"t","message":{"role":"assistant","content":""},"done":true,"prompt_eval_count":3,"eval_count":4}' ,
2164+ ] ,
2165+ async ( ) => {
2166+ const stream = await createOllamaTestStream ( {
2167+ baseUrl : "http://ollama-host:11434" ,
2168+ model : { id : "kimi-k2.6:cloud" , provider : "ollama" } ,
2169+ } ) ;
2170+ const events = await collectStreamEvents ( stream ) ;
2171+ const textEnd = events . find ( ( event ) => event . type === "text_end" ) ;
2172+ const doneEvent = events . at ( - 1 ) ;
2173+
2174+ expect ( textEnd ?. content ) . toBe ( visibleAnswer ) ;
2175+ expect ( doneEvent ?. type ) . toBe ( "done" ) ;
2176+ if ( doneEvent ?. type === "done" ) {
2177+ expect ( doneEvent . message . content ) . toEqual ( [ { type : "text" , text : visibleAnswer } ] ) ;
2178+ }
2179+ } ,
2180+ ) ;
2181+ } ) ;
2182+
21422183 it ( "does not leak Kimi inline reasoning when a boundary is followed by tool calls only" , async ( ) => {
21432184 const hiddenPrefix =
21442185 "I should think privately and not leak this planning text in the answer. " +
0 commit comments