Skip to content

Commit 55bef60

Browse files
roomoteedelauna
authored andcommitted
Fix xAI e2e probe isolation
1 parent f4dc16f commit 55bef60

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

apps/vscode-e2e/AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ Background API calls from the extension (usage collection, initialization) hit a
137137
138138
Some suites can't redirect their provider through aimock. These suites patch `globalThis.fetch` directly — the OpenAI SDK resolves `fetch` at API client construction time (which happens lazily at task start), so installing the interceptor before `api.startNewTask()` is sufficient. Installing it before `api.setConfiguration()` (as done below) is the conservative, recommended order.
139139
140+
Keep fetch-interceptor suites hermetic across test cases:
141+
142+
- reset in-memory request/event capture in `setup()` or allocate a fresh per-test buffer instead of reusing shared mutable state implicitly
143+
- scope request-shape assertions to the current probe or test tag only; do not pull in older requests just because they contain tool outputs
144+
- assume late async requests from the prior task can still arrive after a shared array/map was cleared, so tags or other per-probe identity should be the source of truth
145+
- when changing persisted provider/model settings in tests, use the path that clears prior provider fields instead of partial mutation
146+
140147
### Z.ai GLM (`suite/providers/zai.test.ts`)
141148
142149
Z.ai doesn't expose a user-configurable base URL (it uses a fixed set of regional endpoints), so we deliberately avoided adding a hidden test-only override to the schema. The suite instead patches `globalThis.fetch` to intercept requests to `api.z.ai` and return a crafted OpenAI-compatible SSE response.

apps/vscode-e2e/src/suite/providers/xai.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,10 @@ async function runXAIToolProbe(
408408
noToolErrors,
409409
mistakeLimitReached,
410410
completionText,
411-
requests: requests.filter(
412-
(request) => request.probeTag === probeTag || request.functionCallOutputIds.length > 0,
413-
),
411+
// Late retries from the previous probe can still reach the shared capture
412+
// after requests.length = 0. Scope assertions and diagnostics to the
413+
// current probe tag so older tool-result traffic cannot contaminate them.
414+
requests: requests.filter((request) => request.probeTag === probeTag),
414415
transcript,
415416
},
416417
}
@@ -442,6 +443,10 @@ suite("xAI provider", function () {
442443
let loadedFixtures: XAIFixtureFile = {}
443444
let completedRecordings: Map<string, XAIModelFixture> | undefined
444445

446+
setup(() => {
447+
requests.length = 0
448+
})
449+
445450
suiteSetup(async () => {
446451
const isRecord = !!XAI_API_KEY && process.env.XAI_RECORD === "true"
447452
loadedFixtures = await loadXAIFixtures()

0 commit comments

Comments
 (0)