File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,6 +140,16 @@ What should I grab on the way?`;
140140 expect ( stripLeadingInboundMetadata ( input ) ) . toBe ( "What should I grab on the way?" ) ;
141141 } ) ;
142142
143+ it ( "strips message-tool delivery hints before leading metadata blocks" , ( ) => {
144+ const input = `${ MESSAGE_TOOL_ONLY_DELIVERY_HINT } \n\n${ CONV_BLOCK } \n\nActual user message` ;
145+ expect ( stripLeadingInboundMetadata ( input ) ) . toBe ( "Actual user message" ) ;
146+ } ) ;
147+
148+ it ( "strips message-tool delivery hints before leading user text" , ( ) => {
149+ const input = `${ MESSAGE_TOOL_ONLY_DELIVERY_HINT } \n\nActual user message` ;
150+ expect ( stripLeadingInboundMetadata ( input ) ) . toBe ( "Actual user message" ) ;
151+ } ) ;
152+
143153 it ( "strips an active-memory prompt prefix block from leading-only history views even when earlier text precedes it" , ( ) => {
144154 const input = `Queued earlier user turn\n\n${ ACTIVE_MEMORY_PREFIX_BLOCK } \n\nWhat should I grab on the way?` ;
145155 expect ( stripLeadingInboundMetadata ( input ) ) . toBe (
Original file line number Diff line number Diff line change @@ -282,8 +282,21 @@ export function stripLeadingInboundMetadata(text: string): string {
282282 return "" ;
283283 }
284284
285+ const strippedDeliveryHint = isMessageToolDeliveryHintLine ( lines [ index ] ) ;
286+ while ( index < lines . length && isMessageToolDeliveryHintLine ( lines [ index ] ) ) {
287+ index ++ ;
288+ while ( index < lines . length && lines [ index ] === "" ) {
289+ index ++ ;
290+ }
291+ }
292+ if ( index >= lines . length ) {
293+ return "" ;
294+ }
295+
285296 if ( ! isInboundMetaSentinelLine ( lines [ index ] ) ) {
286- const strippedNoLeading = stripTrailingUntrustedContextSuffix ( lines ) ;
297+ const strippedNoLeading = stripTrailingUntrustedContextSuffix (
298+ strippedDeliveryHint ? lines . slice ( index ) : lines ,
299+ ) ;
287300 return strippedNoLeading . join ( "\n" ) ;
288301 }
289302
You can’t perform that action at this time.
0 commit comments