Skip to content

Commit fd83d80

Browse files
Merge branch 'main' into fix/vertex-multi-region-endpoints-1wqbyrd3j4a30
2 parents 9bae9dd + ec204f9 commit fd83d80

6 files changed

Lines changed: 868 additions & 24 deletions

File tree

apps/vscode-e2e/AGENTS.md

Lines changed: 40 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.
@@ -153,6 +160,39 @@ ZAI_API_KEY=<key> TEST_FILE=zai.test pnpm --filter @roo-code/vscode-e2e test:ci
153160
154161
When adding a new test to this suite, add a matching fixture to the `installZAiFetchInterceptor` call in `suiteSetup`. Use a short unique prefix (e.g. `"zai-glm-e2e-mytest:"`) that won't appear in `<environment_details>`.
155162
163+
### xAI Grok (`suite/providers/xai.test.ts`)
164+
165+
xAI uses the **Responses API** (`POST https://api.x.ai/v1/responses`), which is not OpenAI-compatible. aimock can't intercept it. The suite instead patches `globalThis.fetch` to intercept requests to that endpoint. By default it replays hand-crafted SSE events; when a local `fixtures/xai.json` recording exists, it can replay recorded real-API SSE events for reference.
166+
167+
The local `fixtures/xai.json` file is gitignored. It keeps an empty top-level `fixtures` array so aimock can scan the directory without warnings. xAI recordings live under `xaiResponses`, which maps each model ID to `{ readCallId, turn1, turn2 }`:
168+
169+
- **`turn1`** — raw SSE events from the real API for the first API call (should contain a `read_file` function call)
170+
- **`readCallId`** — the `call_id` extracted from turn 1's `response.output_item.done` event; used to match the turn 2 request
171+
- **`turn2`** — raw SSE events for the second API call (should contain an `attempt_completion` call with the correct result text)
172+
173+
Having real-API events in the fixture guarantees:
174+
175+
1. The SSE format expected by the stream processor is correct.
176+
2. The `attempt_completion.result` field contains the actual marker value (not an empty string).
177+
178+
**Recording** (populate or refresh the fixture from the real xAI API):
179+
180+
```sh
181+
XAI_API_KEY=<key> XAI_RECORD=true TEST_FILE=providers/xai.test.js pnpm --filter @roo-code/vscode-e2e test:run
182+
```
183+
184+
This routes all xAI requests through the real API, captures the SSE events per turn, and writes the local gitignored `fixtures/xai.json` on teardown.
185+
186+
**Verifying the recorded fixture in mock mode** (no API key needed):
187+
188+
```sh
189+
TEST_FILE=xai.test pnpm --filter @roo-code/vscode-e2e test:ci:mock
190+
```
191+
192+
When no local recording exists for a model, the interceptor falls back to hand-crafted SSE events (using a hardcoded `readCallId`). CI should use this fallback so the suite remains deterministic and does not depend on large raw provider recordings.
193+
194+
When adding a new test to this suite, update the hand-crafted interceptor response unless the behavior specifically needs a real xAI SSE recording for local debugging. Use a short unique probe tag (e.g. `"xai-e2e:grok-4.20"`) that won't appear in `<environment_details>`.
195+
156196
### DeepSeek V4 (`suite/providers/deepseek-v4.test.ts`)
157197
158198
DeepSeek exposes `deepSeekBaseUrl`, so the suite redirects the OpenAI-compatible DeepSeek client through aimock with `deepSeekBaseUrl: ${AIMOCK_URL}/v1`. The test still installs a lightweight fetch capture for request-shape assertions, but responses should come from aimock fixtures or aimock record mode.

apps/vscode-e2e/fixtures/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# Contributors should extract stable fixtures manually from these files, then delete them.
33
openai-*.json
44
anthropic-*.json
5+
xai.json

0 commit comments

Comments
 (0)