feat: add controlled codex thread compaction

This commit is contained in:
AI Bot
2026-06-03 13:39:01 +08:00
parent 7a30c2a8d9
commit 0fb588e339
11 changed files with 362 additions and 0 deletions

View File

@@ -1545,6 +1545,34 @@ test("codex app-server runner rolls back a thread without starting a new turn or
assert.equal(result.turnId, undefined);
});
test("codex app-server runner starts thread compaction without starting a normal turn or leaking history", async () => {
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
codexAppServerEnabled: true,
codexAppServerCommand: process.execPath,
codexAppServerArgs: ["tests/fixtures/codex-app-server-runtime.mjs"],
codexAppServerWorkdir: repoRoot,
codexAppServerTimeoutMs: 5000,
});
const result = await executeCodexAppServerTask(runnerConfig, {
taskId: "task-thread-compact",
taskType: "conversation_reply",
intentCategory: "thread_compact",
targetCodexThreadRef: "019d-app-server-thread",
targetCodexFolderRef: repoRoot,
executionPrompt: "压缩当前 Codex 线程上下文。",
});
assert.equal(result.status, "completed");
assert.equal(result.threadId, "019d-app-server-thread");
assert.equal(result.turnControl, "compact");
assert.equal(result.compaction?.status, "completed");
assert.match(result.replyBody, /已发起 Codex 线程上下文压缩/);
assert.doesNotMatch(JSON.stringify(result), /context-compaction-secret-should-not-leak/);
assert.doesNotMatch(JSON.stringify(result), /private compaction summary should not leak/);
assert.equal(result.turnId, undefined);
});
test("codex app-server runner stays disabled unless feature flag is explicit", () => {
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
codexAppServerCommand: process.execPath,