@@ -1891,6 +1891,43 @@ describe("OpenResponses HTTP API (e2e)", () => {
18911891 await ensureResponseConsumed ( res ) ;
18921892 } ) ;
18931893
1894+ it ( "keeps base64 input_file text truncation UTF-16 safe" , async ( ) => {
1895+ const port = enabledPort ;
1896+ const text = `${ "a" . repeat ( 59_999 ) } 😀tail` ;
1897+ agentCommand . mockClear ( ) ;
1898+ agentCommand . mockResolvedValueOnce ( { payloads : [ { text : "ok" } ] } as never ) ;
1899+
1900+ const res = await postResponses ( port , {
1901+ model : "openclaw" ,
1902+ input : [
1903+ {
1904+ type : "message" ,
1905+ role : "user" ,
1906+ content : [
1907+ {
1908+ type : "input_file" ,
1909+ source : {
1910+ type : "base64" ,
1911+ media_type : "text/plain" ,
1912+ data : Buffer . from ( text ) . toString ( "base64" ) ,
1913+ filename : "emoji-boundary.txt" ,
1914+ } ,
1915+ } ,
1916+ ] ,
1917+ } ,
1918+ ] ,
1919+ } ) ;
1920+
1921+ expect ( res . status ) . toBe ( 200 ) ;
1922+ expect ( agentCommand ) . toHaveBeenCalledTimes ( 1 ) ;
1923+ const opts = firstAgentOpts ( ) ;
1924+ const extraSystemPrompt = ( opts as { extraSystemPrompt ?: string } ) . extraSystemPrompt ?? "" ;
1925+ expect ( extraSystemPrompt ) . toContain ( '<file name="emoji-boundary.txt">' ) ;
1926+ expect ( extraSystemPrompt ) . not . toContain ( "😀" ) ;
1927+ expect ( extraSystemPrompt ) . not . toMatch ( / [ \uD800 - \uDBFF ] (? ! [ \uDC00 - \uDFFF ] ) / u) ;
1928+ await ensureResponseConsumed ( res ) ;
1929+ } ) ;
1930+
18941931 it ( "still rejects input with neither text nor image" , async ( ) => {
18951932 const port = enabledPort ;
18961933 agentCommand . mockClear ( ) ;
0 commit comments