@@ -80,6 +80,14 @@ describe("gateway ws log helpers", () => {
8080 expect ( out ) . toContain ( "…" ) ;
8181 } ) ;
8282
83+ test . each ( [
84+ [ "string" , `${ "a" . repeat ( 239 ) } 😀tail` ] ,
85+ [ "Error" , Object . assign ( new Error ( `${ "a" . repeat ( 239 ) } 😀tail` ) , { name : "" } ) ] ,
86+ [ "message-like object" , { message : `${ "a" . repeat ( 239 ) } 😀tail` } ] ,
87+ ] ) ( "formatForLog keeps bounded %s values UTF-16 safe" , ( _name , input ) => {
88+ expect ( formatForLog ( input ) ) . toBe ( `${ "a" . repeat ( 239 ) } ...` ) ;
89+ } ) ;
90+
8391 test ( "summarizeAgentEventForWsLog compacts assistant payloads" , ( ) => {
8492 const summary = summarizeAgentEventForWsLog ( {
8593 runId : "12345678-1234-1234-1234-123456789abc" ,
@@ -102,6 +110,15 @@ describe("gateway ws log helpers", () => {
102110 expect ( summary . text ) . not . toContain ( "\n" ) ;
103111 } ) ;
104112
113+ test ( "summarizeAgentEventForWsLog keeps compact previews UTF-16 safe" , ( ) => {
114+ const summary = summarizeAgentEventForWsLog ( {
115+ stream : "assistant" ,
116+ data : { text : `${ "a" . repeat ( 158 ) } 😀tail` } ,
117+ } ) ;
118+
119+ expect ( summary . text ) . toBe ( `${ "a" . repeat ( 158 ) } …` ) ;
120+ } ) ;
121+
105122 test ( "summarizeAgentEventForWsLog includes tool metadata" , ( ) => {
106123 const summary = summarizeAgentEventForWsLog ( {
107124 runId : "run-1" ,
0 commit comments