@@ -878,6 +878,55 @@ describe("createGmailTools", () => {
878878 expect ( await headersFor ( [ "SENT" ] ) ) . toContain ( "To: ada@example.com" ) ;
879879 } ) ;
880880
881+ test ( "reply drafts fall back to the sender when Reply-To has no address" , async ( ) => {
882+ let raw = "" ;
883+ const tools = createGmailTools ( {
884+ capabilities : testCapabilities ( async ( input , init ) => {
885+ if ( new URL ( String ( input ) ) . pathname . endsWith ( "/messages/message-1" ) ) {
886+ return new Response (
887+ JSON . stringify ( {
888+ id : "message-1" ,
889+ labelIds : [ "INBOX" ] ,
890+ payload : {
891+ mimeType : "text/plain" ,
892+ headers : [
893+ { name : "From" , value : "Sender <sender@example.com>" } ,
894+ { name : "Reply-To" , value : "undisclosed-recipients:;" } ,
895+ { name : "Subject" , value : "Hello" } ,
896+ ] ,
897+ body : { data : encodeBase64Url ( "Original" ) } ,
898+ } ,
899+ } ) ,
900+ ) ;
901+ }
902+ raw = draftRawFromRequest ( init ) ;
903+ return new Response ( JSON . stringify ( { id : "draft-1" } ) ) ;
904+ } ) ,
905+ } ) ;
906+ await tools . run (
907+ {
908+ id : "call-reply" ,
909+ name : "gmail_create_draft" ,
910+ arguments : { replyToMessageId : "message-1" , body : "Thanks" } ,
911+ } ,
912+ new AbortController ( ) . signal ,
913+ ) ;
914+ await tools . dispose ( ) ;
915+ expect ( Buffer . from ( raw , "base64url" ) . toString ( ) ) . toContain (
916+ "To: sender@example.com\r\n" ,
917+ ) ;
918+ } ) ;
919+
920+ test ( "trims reply subjects before checking the Re: prefix" , ( ) => {
921+ const raw = createRawDraft (
922+ { body : "Reply" } ,
923+ { messageId : "<message-1@example.com>" , subject : " Re: Original " } ,
924+ ) ;
925+ expect ( Buffer . from ( raw , "base64url" ) . toString ( ) ) . toContain (
926+ "Subject: Re: Original\r\n" ,
927+ ) ;
928+ } ) ;
929+
881930 test ( "keeps an existing Re: prefix on reply subjects" , ( ) => {
882931 const raw = createRawDraft (
883932 { body : "Reply" } ,
0 commit comments