diff --git a/packages/core/src/tools/agent/agent.test.ts b/packages/core/src/tools/agent/agent.test.ts index caf17360d57..0f1c57efcf7 100644 --- a/packages/core/src/tools/agent/agent.test.ts +++ b/packages/core/src/tools/agent/agent.test.ts @@ -898,6 +898,16 @@ describe('AgentTool', () => { ).toMatch(/fork/i); }); + it('rejects a non-boolean run_in_background value', () => { + expect( + agentTool.validateToolParams({ + ...validParams, + // @ts-expect-error: raw model parameters are untrusted + run_in_background: 'true', + }), + ).toMatch(/run_in_background.*boolean/i); + }); + it('rejects working_dir combined with run_in_background', () => { expect( agentTool.validateToolParams({ diff --git a/packages/core/src/tools/agent/agent.ts b/packages/core/src/tools/agent/agent.ts index 003a8ae4bb5..ca1148b4fb2 100644 --- a/packages/core/src/tools/agent/agent.ts +++ b/packages/core/src/tools/agent/agent.ts @@ -1007,6 +1007,13 @@ assistant: Uses the ${ToolNames.AGENT} tool to launch the test-runner agent return 'Parameter "prompt" must be a non-empty string.'; } + if ( + params.run_in_background !== undefined && + typeof params.run_in_background !== 'boolean' + ) { + return 'Parameter "run_in_background" must be a boolean when set.'; + } + if (params.subagent_type !== undefined) { if ( typeof params.subagent_type !== 'string' ||