@@ -21,6 +21,7 @@ import { ApplyGuardrailCommand, BedrockRuntimeClient } from '@aws-sdk/client-bed
2121import { GetSecretValueCommand , SecretsManagerClient } from '@aws-sdk/client-secrets-manager' ;
2222import { logger } from './logger' ;
2323import { loadMemoryContext , type MemoryContext } from './memory' ;
24+ import { sanitizeExternalContent } from './sanitization' ;
2425import { isPrTaskType , type TaskRecord , type TaskType } from './types' ;
2526
2627// ---------------------------------------------------------------------------
@@ -727,12 +728,12 @@ export function assembleUserPrompt(
727728 parts . push ( `Repository: ${ repo } ` ) ;
728729
729730 if ( issue ) {
730- parts . push ( `\n## GitHub Issue #${ issue . number } : ${ issue . title } \n` ) ;
731- parts . push ( issue . body || '(no description)' ) ;
731+ parts . push ( `\n## GitHub Issue #${ issue . number } : ${ sanitizeExternalContent ( issue . title ) } \n` ) ;
732+ parts . push ( sanitizeExternalContent ( issue . body ) || '(no description)' ) ;
732733 if ( issue . comments . length > 0 ) {
733734 parts . push ( '\n### Comments\n' ) ;
734735 for ( const c of issue . comments ) {
735- parts . push ( `**@${ c . author } **: ${ c . body } \n` ) ;
736+ parts . push ( `**@${ sanitizeExternalContent ( c . author ) } **: ${ sanitizeExternalContent ( c . body ) } \n` ) ;
736737 }
737738 }
738739 }
@@ -767,8 +768,8 @@ export function assemblePrIterationPrompt(
767768
768769 parts . push ( `Task ID: ${ taskId } ` ) ;
769770 parts . push ( `Repository: ${ repo } ` ) ;
770- parts . push ( `\n## Pull Request #${ pr . number } : ${ pr . title } \n` ) ;
771- parts . push ( pr . body || '(no description)' ) ;
771+ parts . push ( `\n## Pull Request #${ pr . number } : ${ sanitizeExternalContent ( pr . title ) } \n` ) ;
772+ parts . push ( sanitizeExternalContent ( pr . body ) || '(no description)' ) ;
772773 parts . push ( `\nBase branch: ${ pr . base_ref } ` ) ;
773774 parts . push ( `Head branch: ${ pr . head_ref } ` ) ;
774775
@@ -806,13 +807,13 @@ export function assemblePrIterationPrompt(
806807 for ( const [ rootId , root ] of rootComments ) {
807808 const location = root . path ? `\`${ root . path } ${ root . line ? `:${ root . line } ` : '' } \`` : 'general' ;
808809 parts . push ( `**Thread on ${ location } ** (reply with comment_id: ${ rootId } )` ) ;
809- parts . push ( `> **@${ root . author } **: ${ root . body } ` ) ;
810+ parts . push ( `> **@${ sanitizeExternalContent ( root . author ) } **: ${ sanitizeExternalContent ( root . body ) } ` ) ;
810811 if ( root . diff_hunk ) {
811812 parts . push ( `> \`\`\`diff\n> ${ root . diff_hunk } \n> \`\`\`` ) ;
812813 }
813814 const threadReplies = replies . get ( rootId ) ?? [ ] ;
814815 for ( const r of threadReplies ) {
815- parts . push ( `\n - **@${ r . author } **: ${ r . body } ` ) ;
816+ parts . push ( `\n - **@${ sanitizeExternalContent ( r . author ) } **: ${ sanitizeExternalContent ( r . body ) } ` ) ;
816817 }
817818 parts . push ( '' ) ;
818819 }
@@ -824,7 +825,7 @@ export function assemblePrIterationPrompt(
824825 const location = r . path ? `\`${ r . path } ${ r . line ? `:${ r . line } ` : '' } \`` : 'general' ;
825826 const replyTarget = r . in_reply_to_id ?? r . id ;
826827 parts . push ( `**Comment on ${ location } ** (reply with comment_id: ${ replyTarget } )` ) ;
827- parts . push ( `> **@${ r . author } **: ${ r . body } ` ) ;
828+ parts . push ( `> **@${ sanitizeExternalContent ( r . author ) } **: ${ sanitizeExternalContent ( r . body ) } ` ) ;
828829 if ( r . diff_hunk ) {
829830 parts . push ( `> \`\`\`diff\n> ${ r . diff_hunk } \n> \`\`\`` ) ;
830831 }
@@ -836,7 +837,7 @@ export function assemblePrIterationPrompt(
836837 if ( pr . issue_comments . length > 0 ) {
837838 parts . push ( '\n### Conversation Comments\n' ) ;
838839 for ( const c of pr . issue_comments ) {
839- parts . push ( `**@${ c . author } ** (comment_id: ${ c . id } ): ${ c . body } \n` ) ;
840+ parts . push ( `**@${ sanitizeExternalContent ( c . author ) } ** (comment_id: ${ c . id } ): ${ sanitizeExternalContent ( c . body ) } \n` ) ;
840841 }
841842 }
842843
0 commit comments