From 8f4c0047c2eba8ad610ddb47fa61afa0f7cf8c2f Mon Sep 17 00:00:00 2001 From: Shaojin Wen Date: Tue, 23 Jun 2026 09:18:51 +0800 Subject: [PATCH] fix(test): make ACP set_config_option test use a deterministic openai provider model Follow-up to #5724. The `supports session/set_config_option for mode and model` test asserted that an openai model appears in `availableModels`, which depended on the env-driven OPENAI_MODEL being captured as a runtime-model snapshot and enumerated at session/new. That capture is environment-sensitive: in CI the openai model was absent from `availableModels`, failing `expect(openaiModel).toBeDefined()` (acp-integration.test.ts:535). The earlier QWEN_HOME isolation (#5724) did not address this. Inject an openai provider model via `modelProviders` in the test's settings so the model is a registry entry that is always enumerated and switchable without inference. The test now targets that specific model, making it deterministic regardless of how the ambient openai credentials resolve. Verified locally to pass both with and without OPENAI_MODEL set. --- integration-tests/cli/acp-integration.test.ts | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/integration-tests/cli/acp-integration.test.ts b/integration-tests/cli/acp-integration.test.ts index adb1e989651..9b2af4ea694 100644 --- a/integration-tests/cli/acp-integration.test.ts +++ b/integration-tests/cli/acp-integration.test.ts @@ -467,7 +467,31 @@ function setupAcpTest( it('supports session/set_config_option for mode and model', async () => { const rig = new TestRig(); - rig.setup('acp set config option'); + // Inject a deterministic openai provider model so `availableModels` always + // contains a settable openai entry. The previous version relied on the + // env-driven OPENAI_MODEL being captured as a runtime-model snapshot and + // enumerated, which is environment-sensitive and flaked in CI (the openai + // model could be absent from `availableModels`, failing the assertion + // below). A registry model configured via `modelProviders` is always + // enumerated and switchable without inference, making this test + // deterministic regardless of how the ambient openai credentials resolve. + rig.setup('acp set config option', { + settings: { + modelProviders: { + openai: { + protocol: 'openai', + models: [ + { + id: 'e2e-set-config-option-model', + name: 'E2E Set Config Option Model', + baseUrl: 'https://api.openai.com/v1', + envKey: 'OPENAI_API_KEY', + }, + ], + }, + }, + }, + }); const { sendRequest, cleanup, stderr } = setupAcpTest(rig); @@ -528,9 +552,10 @@ function setupAcpTest( expect(modelOption!.currentValue).toBeTruthy(); // Test: Set model using set_config_option - // Use openai model to avoid auth issues + // Target the deterministic openai provider model injected via settings + // above (avoids auth issues and is always present in `availableModels`). const openaiModel = newSession.models.availableModels.find((model) => - model.modelId.includes('openai'), + model.modelId.includes('e2e-set-config-option-model'), ); expect(openaiModel).toBeDefined();