feat: surface codex reasoning summaries

This commit is contained in:
AI Bot
2026-06-01 18:20:04 +08:00
parent 2ca2737520
commit 5d62560217
11 changed files with 338 additions and 7 deletions

View File

@@ -818,6 +818,58 @@ rl.on("line", (line) => {
},
});
}
if (process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_REASONING_PLAN_EVENTS === "1") {
send({
method: "item/completed",
params: {
threadId: message.params?.threadId,
turnId: "turn-fixture",
item: {
type: "plan",
id: "plan-secret-should-not-leak",
text: "1. 回读官方 App Server item 协议\n2. 补充 reasoning summary 安全映射",
},
},
});
send({
method: "item/started",
params: {
threadId: message.params?.threadId,
turnId: "turn-fixture",
item: {
type: "reasoning",
id: "reasoning-secret-should-not-leak",
summary: [
{
text: "正在判断哪些思考摘要可以展示。",
},
],
content: [
{
text: "raw hidden reasoning token=sk-secret-should-not-leak",
},
],
},
},
});
send({
method: "item/completed",
params: {
threadId: message.params?.threadId,
turnId: "turn-fixture",
item: {
type: "reasoning",
id: "reasoning-secret-should-not-leak",
summary: ["确认只展示官方 summary不展示 raw content。"],
content: [
{
text: "raw hidden chain of thought token=sk-secret-should-not-leak",
},
],
},
},
});
}
send({
method: "item/agentMessage/delta",
params: {

View File

@@ -718,6 +718,58 @@ test("codex app-server runner maps tool, search, image, review, and command acti
}
});
test("codex app-server runner maps item plan and reasoning summary without leaking raw reasoning", async () => {
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_REASONING_PLAN_EVENTS;
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_REASONING_PLAN_EVENTS = "1";
try {
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
codexAppServerEnabled: true,
codexAppServerCommand: process.execPath,
codexAppServerArgs: ["tests/fixtures/codex-app-server-runtime.mjs"],
codexAppServerWorkdir: repoRoot,
codexAppServerTimeoutMs: 5000,
masterAgentModel: "gpt-5.4",
});
const result = await executeCodexAppServerTask(runnerConfig, {
taskId: "task-app-server-reasoning-plan-events",
taskType: "conversation_reply",
targetCodexThreadRef: "019d-app-server-thread",
targetCodexFolderRef: repoRoot,
executionPrompt: "检查 Codex plan 和 reasoning item",
});
assert.equal(result.status, "completed");
assert.deepEqual(result.executionProgress.steps, [
{
id: "plan-item-1",
text: "回读官方 App Server item 协议",
status: "pending",
},
{
id: "plan-item-2",
text: "补充 reasoning summary 安全映射",
status: "pending",
},
]);
assert.deepEqual(result.executionProgress.reasoningSummary, {
status: "completed",
summary: "确认只展示官方 summary不展示 raw content。",
});
const serialized = JSON.stringify(result.executionProgress);
assert.equal(serialized.includes("raw hidden reasoning"), false);
assert.equal(serialized.includes("raw hidden chain of thought"), false);
assert.equal(serialized.includes("sk-secret-should-not-leak"), false);
assert.equal(serialized.includes("reasoning-secret-should-not-leak"), false);
} finally {
if (previous === undefined) {
delete process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_REASONING_PLAN_EVENTS;
} else {
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_REASONING_PLAN_EVENTS = previous;
}
}
});
test("codex app-server runner bridges source thread context into target thread through inject_items", async () => {
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD;
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD = "1";

View File

@@ -611,3 +611,60 @@ test("POST task progress preserves Codex tool activity summaries without leaking
assert.equal(serialized.includes("/Users/kris"), false);
assert.equal(serialized.includes("id_rsa"), false);
});
test("POST task progress preserves Codex reasoning summaries without leaking raw content", async () => {
const task = await data.queueMasterAgentTask({
taskId: "route-progress-reasoning-summary-task",
projectId: "group-progress-test",
taskType: "dispatch_execution",
requestMessageId: "msg-route-progress-reasoning-summary",
requestText: "检查 Codex 思考摘要",
executionPrompt: "检查 Codex 思考摘要",
requestedBy: "krisolo",
requestedByAccount: "krisolo",
deviceId: "mac-studio",
targetProjectId: "master-agent",
targetThreadId: "master-agent-thread",
});
await data.claimNextMasterAgentTask("mac-studio");
const response = await postProgress(
new NextRequest(`http://127.0.0.1:3000/api/v1/master-agent/tasks/${task.taskId}/progress`, {
method: "POST",
headers: {
"content-type": "application/json",
"x-boss-device-token": "boss-mac-studio-token",
},
body: JSON.stringify({
deviceId: "mac-studio",
status: "running",
executionProgress: {
steps: [{ text: "同步 Codex 思考摘要", status: "running" }],
reasoningSummary: {
status: "completed",
summary: "确认只展示官方 summary不展示 raw content token=sk-secret-should-not-persist。",
content: [{ text: "raw hidden chain of thought token=sk-secret-should-not-persist" }],
itemId: "reasoning-secret-should-not-persist",
},
},
}),
}),
{ params: Promise.resolve({ taskId: task.taskId }) },
);
assert.equal(response.status, 200);
const state = await data.readState();
const progress = state.projects
.find((project) => project.id === "master-agent")
?.messages.find((message) => message.executionProgress?.taskId === task.taskId)
?.executionProgress;
assert.deepEqual(progress?.reasoningSummary, {
status: "completed",
summary: "确认只展示官方 summary不展示 raw content token=[redacted]",
});
const serialized = JSON.stringify(progress);
assert.equal(serialized.includes("raw hidden chain of thought"), false);
assert.equal(serialized.includes("sk-secret-should-not-persist"), false);
assert.equal(serialized.includes("reasoning-secret-should-not-persist"), false);
});