Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(maker-core): yield marker 检测收紧为执行器状态头形状(#3763) (#3767)

fico-hub360aeccf70bb
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.ts
index 9800faa2cb..d805712440 100644
--- a/packages/maker-core/src/agents/codex/index.test.ts
+++ b/packages/maker-core/src/agents/codex/index.test.ts
@@ -18183,7 +18183,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -18262,7 +18262,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -18344,7 +18344,7 @@ describe('CodexAgent yield continuation', () => {
cmd: 'pnpm --filter desktop run typecheck',
yield_time_ms: 10_000,
}),
- content: [{ type: 'output_text', text: 'Script running with cell ID 229' }],
+ content: [{ type: 'output_text', text: 'Script running with cell ID 229\nWall time 1.0 seconds\nOutput:\n' }],
},
});
handlers.turnCompleted({
@@ -18396,7 +18396,7 @@ describe('CodexAgent yield continuation', () => {
cmd: 'pnpm --filter desktop run typecheck',
yield_time_ms: 10_000,
}),
- content: [{ type: 'output_text', text: 'Script running with cell ID 229' }],
+ content: [{ type: 'output_text', text: 'Script running with cell ID 229\nWall time 1.0 seconds\nOutput:\n' }],
},
});
handlers.itemCompleted({
@@ -18456,7 +18456,7 @@ describe('CodexAgent yield continuation', () => {
type: 'function_call',
name: 'exec_command',
arguments: JSON.stringify({ cmd: 'pnpm typecheck', yield_time_ms: 10_000 }),
- content: [{ type: 'output_text', text: 'Script running with cell ID 226' }],
+ content: [{ type: 'output_text', text: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n' }],
},
});
handlers.itemCompleted({
@@ -18466,7 +18466,7 @@ describe('CodexAgent yield continuation', () => {
type: 'function_call',
name: 'exec_command',
arguments: JSON.stringify({ cmd: 'pnpm lint', yield_time_ms: 10_000 }),
- content: [{ type: 'output_text', text: 'Script running with cell ID 229' }],
+ content: [{ type: 'output_text', text: 'Script running with cell ID 229\nWall time 1.0 seconds\nOutput:\n' }],
},
});
handlers.itemCompleted({
@@ -18529,7 +18529,7 @@ describe('CodexAgent yield continuation', () => {
cmd: 'pnpm --filter desktop run typecheck',
yield_time_ms: 10_000,
}),
- content: [{ type: 'output_text', text: 'Script running with cell ID 229' }],
+ content: [{ type: 'output_text', text: 'Script running with cell ID 229\nWall time 1.0 seconds\nOutput:\n' }],
},
});
handlers.itemCompleted({
@@ -18698,7 +18698,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -18808,7 +18808,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
await new Promise((resolve) => setTimeout(resolve, 20));
@@ -18863,7 +18863,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -18937,7 +18937,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -18990,7 +18990,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnStarted?.({
@@ -19053,7 +19053,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19122,7 +19122,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19198,7 +19198,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19304,7 +19304,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'inProgress',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.itemCompleted({
@@ -19356,7 +19356,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'inProgress',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.itemCompleted({
@@ -19413,7 +19413,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19541,7 +19541,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19601,7 +19601,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19623,7 +19623,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19645,7 +19645,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19688,7 +19688,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19741,7 +19741,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19798,7 +19798,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -19889,7 +19889,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -20000,7 +20000,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -20070,7 +20070,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -20154,7 +20154,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -20231,7 +20231,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
@@ -20319,7 +20319,7 @@ describe('CodexAgent yield continuation', () => {
type: 'commandExecution',
command: 'pnpm --filter desktop run typecheck',
status: 'completed',
- aggregatedOutput: 'Script running with cell ID 226',
+ aggregatedOutput: 'Script running with cell ID 226\nWall time 1.0 seconds\nOutput:\n',
},
});
handlers.turnCompleted({
diff --git a/packages/maker-core/src/agents/codex/yielded-exec-cell.test.ts b/packages/maker-core/src/agents/codex/yielded-exec-cell.test.ts
index 749b86df32..6e5ea945a1 100644
--- a/packages/maker-core/src/agents/codex/yielded-exec-cell.test.ts
+++ b/packages/maker-core/src/agents/codex/yielded-exec-cell.test.ts
@@ -17,15 +17,47 @@ describe('extractYieldedExecCellIds', () => {
it('keeps later cells in order and dedupes repeats', () => {
expect(extractYieldedExecCellIds([
- 'Script running with cell ID 226',
+ 'Script running with cell ID 226\nWall time 1.0 seconds',
'Script running with cell ID 229 Wall time 11.0 seconds Output:',
- 'Script running with cell ID 226',
+ 'Script running with cell ID 226\nWall time 2.0 seconds',
].join('\n'))).toEqual(['226', '229']);
});
it('ignores finished command output without a yield marker', () => {
expect(extractYieldedExecCellIds('Exit 0\n\n> tsc --noEmit\n')).toEqual([]);
});
+
+ // Windows 路径:执行器状态头以 CRLF 分行时同样是真实 yield,不得漏判(假完成)。
+ it('recognizes a CRLF-delimited executor status header', () => {
+ expect(extractYieldedExecCellIds(
+ 'Script running with cell ID 226\r\nWall time 11.0 seconds\r\nOutput:\r\n',
+ )).toEqual(['226']);
+ expect(extractYieldedExecCellIds(
+ 'chunk done\r\nScript running with cell ID 42\r\nWall time 1.0 seconds\r\n',
+ )).toEqual(['42']);
+ });
+
+ // #3763:被引用/示例出现的 marker 文案不是执行器状态头,不得铸造 cell。
+ it('ignores quoted or prefixed markers that are not executor status headers', () => {
+ // grep 输出:路径:行号: 前缀,不在物理行首。
+ expect(extractYieldedExecCellIds(
+ "src/x.test.ts:14: 'Script running with cell ID 226\\nWall time 11.0 seconds',",
+ )).toEqual([]);
+ // 源码 cat:缩进 + 引号包裹,\n 是字面转义不是真实换行。
+ expect(extractYieldedExecCellIds(
+ " 'Script running with cell ID 229\\nWall time 11.0 seconds\\nOutput:\\n',",
+ )).toEqual([]);
+ // 行首但缺 Wall time 帧(裸引用一行文案)。
+ expect(extractYieldedExecCellIds('Script running with cell ID 777')).toEqual([]);
+ // issue 复现形态:一次读取源码把多个示例 ID 全炸出来 —— 现在必须为空。
+ expect(extractYieldedExecCellIds([
+ " it('locks the #3179 rollout yield shape', () => {",
+ " expect(extractYieldedExecCellIds(",
+ " 'Script running with cell ID 226\\nWall time 11.0 seconds\\nOutput:\\n',",
+ " )).toEqual(['226']);",
+ " 'Script running with cell ID 229 Wall time', 'cell ID 11', 'cell ID 12',",
+ ].join('\n'))).toEqual([]);
+ });
});
describe('extractYieldedExecCellsFromCodexItem', () => {
@@ -51,13 +83,29 @@ describe('extractYieldedExecCellsFromCodexItem', () => {
workdir: '/repo',
yield_time_ms: 10_000,
}),
- content: [{ type: 'output_text', text: 'Script running with cell ID 229' }],
+ content: [{ type: 'output_text', text: 'Script running with cell ID 229\nWall time 10.0 seconds\nOutput:\n' }],
})).toEqual([{
cellId: '229',
command: 'pnpm --filter desktop run typecheck',
}]);
});
+ // #3763:已完成命令的 stdout 引用 marker 示例,不得铸造 continuation claim。
+ it('does not mint cells from a completed exec whose stdout merely quotes markers', () => {
+ expect(extractYieldedExecCellsFromCodexItem({
+ type: 'commandExecution',
+ id: 'item-quoted',
+ command: 'grep -rn "cell ID" src/',
+ status: 'completed',
+ exitCode: 0,
+ aggregatedOutput: [
+ "src/a.test.ts:14: 'Script running with cell ID 226\\nWall time 11.0 seconds',",
+ "src/a.test.ts:21: 'Script running with cell ID 229 Wall time 11.0 seconds Output:',",
+ "src/a.test.ts:75: text: 'I will wait. Script running with cell ID 777',",
+ ].join('\n'),
+ })).toEqual([]);
+ });
+
it('does not treat a finished exec item as a yielded cell', () => {
expect(extractYieldedExecCellsFromCodexItem({
type: 'commandExecution',
@@ -82,7 +130,7 @@ describe('extractYieldedExecCellsFromCodexItem', () => {
type: 'commandExecution',
id: 'item-late-marker',
command: 'pnpm --filter desktop run typecheck',
- aggregatedOutput: `${padding}\nScript running with cell ID 226`,
+ aggregatedOutput: `${padding}\nScript running with cell ID 226\nWall time 30.0 seconds\nOutput:\n`,
})).toEqual([{
cellId: '226',
command: 'pnpm --filter desktop run typecheck',
diff --git a/packages/maker-core/src/agents/codex/yielded-exec-cell.ts b/packages/maker-core/src/agents/codex/yielded-exec-cell.ts
index e9fd94142a..a4aba1c909 100644
--- a/packages/maker-core/src/agents/codex/yielded-exec-cell.ts
+++ b/packages/maker-core/src/agents/codex/yielded-exec-cell.ts
@@ -14,8 +14,19 @@ export interface YieldedExecCell {
command?: string;
}
-/** Locked to the #3179 Codex rollout shape. Do not loosen without a new fixture. */
-export const YIELDED_EXEC_CELL_RE = /Script running with cell ID[ \t]+(\d+)/gi;
+/**
+ * Locked to the #3179 Codex rollout shape. Do not loosen without a new fixture.
+ *
+ * #3763 收紧:真实 yield 通知是执行器的**状态头**——marker 行从物理行首开始,
+ * 且紧跟 `Wall time` 帧(同一行以空白分隔,或下一物理行)。被引用/示例出现的
+ * 文案(grep 的 `路径:行号:` 前缀、源码里的缩进+引号、字面 `\n` 转义)都不满足
+ * 这两条,不再被当成真实 cell 铸造 continuation claim —— 此前误判会让已成功的
+ * 命令等待不存在的 cell,升级成 yield-continuation-lost-handle 终态失败。
+ * 残余盲区:纯文本恰好在列 0 完整复刻两行状态头 —— 与真实执行器输出无法区分,
+ * 接受(协议级 executionHandle 落地前的启发式边界)。
+ */
+export const YIELDED_EXEC_CELL_RE =
+ /(?:^|\r?\n)Script running with cell ID[ \t]+(\d+)(?:[ \t]+|\r?\n)Wall time[ \t]/gi;
const MAX_SCAN_CHARS = 16_384;