kimi-code/packages/agent-core/test/setup.ts
7Sageer 95a656ca61
fix(agent-core): strip the no-op subagent model parameter while the secondary-model experiment is off (#2449)
The Agent/AgentSwarm tool schemas always advertised a \`model\` choice
parameter, so the secondary-model concept entered the prompt even with
the experiment disabled. Gate the advertised JSON schema on the flag in
both engines: off (the default) drops the parameter, on keeps it, and
spawn-time resolution already falls back to the caller's model either
way.

Also scrub ambient KIMI_CODE_EXPERIMENTAL_* env vars in both packages'
vitest setup so flag-dependent tool schemas in llm.tools_snapshot stay
deterministic regardless of the developer shell.
2026-07-31 13:09:56 +08:00

13 lines
554 B
TypeScript

/**
* Hermetic experimental-flag state for tests: scrub ambient
* `KIMI_CODE_EXPERIMENTAL_*` env vars inherited from the developer shell
* (e.g. a globally exported `KIMI_CODE_EXPERIMENTAL_FLAG=1`) so flag-driven
* behavior — including tool schemas embedded in `llm.tools_snapshot`
* snapshots — stays deterministic and matches CI. Tests opt into flags
* explicitly via `vi.stubEnv` or harness flag options.
*/
for (const key of Object.keys(process.env)) {
if (key.startsWith('KIMI_CODE_EXPERIMENTAL_')) {
delete process.env[key];
}
}