You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/vscode-e2e/AGENTS.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,6 +137,13 @@ Background API calls from the extension (usage collection, initialization) hit a
137
137
138
138
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.
139
139
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
+
140
147
### Z.ai GLM (`suite/providers/zai.test.ts`)
141
148
142
149
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.
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>`.
155
162
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`functioncall)
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):
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>`.
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.
0 commit comments