@@ -664,6 +664,61 @@ describe("handleToolExecutionEnd media emission", () => {
664664 expect ( ctx . state . pendingToolTrustedLocalMedia ) . toBe ( true ) ;
665665 } ) ;
666666
667+ it ( "does NOT queue structured media marked as non-outbound" , async ( ) => {
668+ const ctx = createMockContext ( {
669+ shouldEmitToolOutput : false ,
670+ onToolResult : vi . fn ( ) ,
671+ builtinToolNames : new Set ( [ "message" ] ) ,
672+ } ) ;
673+
674+ await handleToolExecutionEnd ( ctx , {
675+ type : "tool_execution_end" ,
676+ toolName : "message" ,
677+ toolCallId : "tc-1" ,
678+ isError : false ,
679+ result : {
680+ content : [ { type : "text" , text : "Downloaded Slack file to /tmp/report.pdf" } ] ,
681+ details : {
682+ media : {
683+ mediaUrl : "/tmp/report.pdf" ,
684+ outbound : false ,
685+ } ,
686+ } ,
687+ } ,
688+ } ) ;
689+
690+ expect ( ctx . state . pendingToolMediaUrls ) . toStrictEqual ( [ ] ) ;
691+ } ) ;
692+
693+ it ( "does NOT queue image fallback paths when media is marked as non-outbound" , async ( ) => {
694+ const ctx = createMockContext ( {
695+ shouldEmitToolOutput : false ,
696+ onToolResult : vi . fn ( ) ,
697+ builtinToolNames : new Set ( [ "message" ] ) ,
698+ } ) ;
699+
700+ await handleToolExecutionEnd ( ctx , {
701+ type : "tool_execution_end" ,
702+ toolName : "message" ,
703+ toolCallId : "tc-1" ,
704+ isError : false ,
705+ result : {
706+ content : [
707+ { type : "text" , text : "Downloaded Slack image" } ,
708+ { type : "image" , data : "base64" , mimeType : "image/png" } ,
709+ ] ,
710+ details : {
711+ path : "/tmp/slack-image.png" ,
712+ media : {
713+ outbound : false ,
714+ } ,
715+ } ,
716+ } ,
717+ } ) ;
718+
719+ expect ( ctx . state . pendingToolMediaUrls ) . toStrictEqual ( [ ] ) ;
720+ } ) ;
721+
667722 it ( "queues trusted TTS local media when the exact built-in name is absent" , async ( ) => {
668723 const ctx = createMockContext ( {
669724 shouldEmitToolOutput : false ,
0 commit comments