@@ -42,18 +42,7 @@ export class AgentGraphProviderScenario {
4242 constructor ( private readonly childResultText : string ) { }
4343
4444 respond ( body : Record < string , unknown > , reply : AgentGraphProviderReply ) : void {
45- // The scenario follows user requests, not the Host's ephemeral environment snapshot.
46- body = {
47- ...body ,
48- messages : ( Array . isArray ( body . messages ) ? body . messages : [ ] ) . filter (
49- ( message ) =>
50- ! (
51- message . role === 'user' &&
52- typeof message . content === 'string' &&
53- message . content . startsWith ( 'Runtime Host environment for this turn' )
54- ) ,
55- ) ,
56- } ;
45+ body = withoutRuntimeHostEnvironment ( body ) ;
5746 const names = toolNames ( body ) ;
5847 // Read covers both files and the child's Session-scoped tool results.
5948 if ( names . join ( ',' ) === 'Glob,Grep,Read' ) {
@@ -215,6 +204,7 @@ export class GatedSwarmProviderScenario {
215204 }
216205
217206 async respond ( body : Record < string , unknown > , reply : AgentGraphProviderReply ) : Promise < void > {
207+ body = withoutRuntimeHostEnvironment ( body ) ;
218208 const names = toolNames ( body ) ;
219209 if ( names . join ( ',' ) === 'Glob,Grep,Read' ) {
220210 const index = this . #childrenRequested++ ;
@@ -319,6 +309,21 @@ export class GatedSwarmProviderScenario {
319309 }
320310}
321311
312+ function withoutRuntimeHostEnvironment ( body : Record < string , unknown > ) : Record < string , unknown > {
313+ // The scenario follows user requests, not the Host's ephemeral environment snapshot.
314+ return {
315+ ...body ,
316+ messages : ( Array . isArray ( body . messages ) ? body . messages : [ ] ) . filter (
317+ ( message ) =>
318+ ! (
319+ message . role === 'user' &&
320+ typeof message . content === 'string' &&
321+ message . content . startsWith ( 'Runtime Host environment for this turn' )
322+ ) ,
323+ ) ,
324+ } ;
325+ }
326+
322327function toolNames ( body : Record < string , unknown > ) : string [ ] {
323328 const tools = Array . isArray ( body . tools ) ? body . tools : [ ] ;
324329 return tools
0 commit comments