fix(tools): enforce a disabled run_in_background at execution time (review findings)

enableRunInBackground: false removed the parameter from the advertised
schema only — the arg validator deliberately allows undeclared keys, so
a caller (or a model that has seen the parameter elsewhere) could still
force run_in_background: true and start background work past the
deployment's opt-out, in both tool-bash and tool-subagent. Both
producers now refuse the forced key loud in execute(); tests pin the
refusal (and that nothing spawns) alongside the untouched foreground
path; the schema-omission-is-advertising rule is recorded in the
runtime RFC and both READMEs.
This commit is contained in:
Yichen Jiang
2026-07-09 23:37:51 +08:00
parent 3ad561862f
commit 35acd34fd9
7 changed files with 41 additions and 3 deletions

View File

@@ -408,6 +408,15 @@ describe('background execution through the task runtime', () => {
// The registry-held definition agrees (schema and capability never disagree).
const parameters = ctx.tools.get('bash')!.parameters as { properties: Record<string, unknown> }
expect('run_in_background' in parameters.properties).toBe(false)
// Schema omission is advertising, not enforcement: the arg validator
// allows undeclared keys, so a forced run_in_background must be REFUSED
// at execution time (review finding) — while foreground still works.
const forced = await call(ctx, 'bash', { command: 'echo hi', description: 'test command', run_in_background: true })
expect(forced.isError).toBe(true)
expect(text(forced)).toContain('run_in_background is disabled for this deployment')
const foreground = await call(ctx, 'bash', { command: 'echo hi', description: 'test command' })
expect(foreground.isError).toBe(false)
})
})