Skip to content

Commit 30cc87a

Browse files
authored
test(qa): model Codex compaction in parity mock (#105493)
* test(qa): model codex compaction in parity mock * docs(agents): record gh branch lookup syntax
1 parent 9686048 commit 30cc87a

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

‎AGENTS.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Skills own workflows; root owns hard policy and routing.
147147
- Crabbox wrapper `stop` has no `--timing-json`; use `node scripts/crabbox-wrapper.mjs stop --provider <provider> --id <id>`.
148148
- Repo-native PR worktree may omit `node_modules`; prove remotely, then use `git commit --no-verify`, not `scripts/committer`.
149149
- Parallel agents share the checkout; never switch its branch while sibling work runs.
150+
- Testbox status: `blacksmith testbox status --id <tbx_id>`; no `--json` flag.
151+
- QA CLI `--output-dir` must be repo-relative.
150152
- Full suites, changed gates, builds, typechecks, lint fan-out, Docker/package/E2E/live/cross-OS proof, or anything computationally intensive: Crabbox/Testbox.
151153
- If an allowed local fallback fans out or becomes expensive, stop it and move the work to the pre-warmed remote box.
152154
- Before handoff/push: prove touched surface. Before landing to `main`: issue proof plus appropriate full/broad proof unless scope is clearly narrow.
@@ -165,6 +167,7 @@ Skills own workflows; root owns hard policy and routing.
165167
- Use `$openclaw-pr-maintainer` immediately for maintainer-side OpenClaw issue/PR review, triage, duplicates, labels, comments, close, land, or evidence. Contributor PR creation/refresh follows the requested contributor workflow; linked refs alone do not require maintainer archive tooling.
166168
- Issue/PR start: `git status -sb`; if clean, `git pull --ff-only`; if dirty, yell before pull/rebase.
167169
- PR refs: `gh pr view/diff` or `gh api`, not web search. Prefer `gitcrawl` for maintainer discovery; missing/stale `gitcrawl` falls through to live `gh`, not contributor setup. Verify live with `gh` before mutation.
170+
- `gh pr view` takes the branch positionally; no `--head` flag.
168171
- zsh: quote `gh api` endpoints containing `?` or brackets; otherwise glob expansion corrupts the invocation.
169172
- GitHub Actions: resolve workflow files from `.github/workflows` or API; never infer filenames from display names.
170173
- zsh: quote command globs; unmatched patterns abort before the tool runs.

‎extensions/qa-lab/src/providers/mock-openai/server.test.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4795,6 +4795,43 @@ describe("qa mock openai server", () => {
47954795
expect(outputText(await response.json())).toContain("model switch handoff confirmed");
47964796
});
47974797

4798+
it("returns the Codex remote-compaction-v2 response shape", async () => {
4799+
const server = await startQaMockOpenAiServer({
4800+
host: "127.0.0.1",
4801+
port: 0,
4802+
});
4803+
cleanups.push(async () => {
4804+
await server.stop();
4805+
});
4806+
4807+
const response = await fetch(`${server.baseUrl}/v1/responses`, {
4808+
method: "POST",
4809+
headers: {
4810+
"content-type": "application/json",
4811+
},
4812+
body: JSON.stringify({
4813+
stream: true,
4814+
input: [
4815+
{
4816+
role: "user",
4817+
content: [{ type: "input_text", text: "Retained context." }],
4818+
},
4819+
{ type: "compaction_trigger" },
4820+
],
4821+
}),
4822+
});
4823+
4824+
expect(response.status).toBe(200);
4825+
const body = await response.text();
4826+
expect(body).toContain('"type":"response.output_item.done"');
4827+
expect(body).toContain('"type":"compaction"');
4828+
expect(body).toContain('"encrypted_content":"QA_MOCK_REMOTE_COMPACTION_SUMMARY"');
4829+
expect(body).toContain('"type":"response.completed"');
4830+
const debugResponse = await fetch(`${server.baseUrl}/debug/requests`);
4831+
expect(debugResponse.status).toBe(200);
4832+
expect(await debugResponse.json()).toEqual([]);
4833+
});
4834+
47984835
it("returns NO_REPLY for unmentioned group chatter", async () => {
47994836
const server = await startQaMockOpenAiServer({
48004837
host: "127.0.0.1",

‎extensions/qa-lab/src/providers/mock-openai/server.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,34 @@ function writeSse(res: ServerResponse, events: StreamEvent[]) {
329329
res.end(body);
330330
}
331331

332+
function isRemoteCompactionV2Request(input: ResponsesInputItem[]) {
333+
// Codex sends compaction through /responses with a trigger item. Keep it
334+
// outside scenario dispatch so maintenance calls never become tool evidence.
335+
return input.some((item) => item.type === "compaction_trigger");
336+
}
337+
338+
function buildRemoteCompactionV2Events(): [
339+
Extract<StreamEvent, { type: "response.output_item.done" }>,
340+
Extract<StreamEvent, { type: "response.completed" }>,
341+
] {
342+
const item = {
343+
type: "compaction",
344+
encrypted_content: "QA_MOCK_REMOTE_COMPACTION_SUMMARY",
345+
};
346+
return [
347+
{ type: "response.output_item.done", item },
348+
{
349+
type: "response.completed",
350+
response: {
351+
id: "resp_mock_compaction_1",
352+
status: "completed",
353+
output: [item],
354+
usage: { input_tokens: 64, output_tokens: 16, total_tokens: 80 },
355+
},
356+
},
357+
];
358+
}
359+
332360
async function writeSseWithPreviewPause(
333361
res: ServerResponse,
334362
events: StreamEvent[],
@@ -3921,6 +3949,15 @@ export async function startQaMockOpenAiServer(params?: {
39213949
return;
39223950
}
39233951
const input = Array.isArray(body.input) ? (body.input as ResponsesInputItem[]) : [];
3952+
if (isRemoteCompactionV2Request(input)) {
3953+
const events = buildRemoteCompactionV2Events();
3954+
if (body.stream === false) {
3955+
writeJson(res, 200, events[1].response);
3956+
} else {
3957+
writeSse(res, events);
3958+
}
3959+
return;
3960+
}
39243961
const prompt = extractLastUserText(input);
39253962
const allInputText = extractAllRequestTexts(input, body);
39263963
const inflightRequestId = nextInflightRequestId++;

0 commit comments

Comments
 (0)