




















@@ -1406,6 +1406,46 @@ describe("CodexAppServerEventProjector", () => {
14061406expect(toolResult.result).toEqual({ status: "completed", exitCode: 0, durationMs: 42 });
14071407});
140814081409+it("uses streamed command output for failed native tool errors", async () => {
1410+const projector = await createProjector();
1411+1412+await projector.handleNotification(
1413+forCurrentTurn("item/commandExecution/outputDelta", {
1414+itemId: "cmd-streamed-failure",
1415+delta: "fatal: missing fixture\n",
1416+}),
1417+);
1418+await projector.handleNotification(
1419+turnCompleted([
1420+{
1421+type: "commandExecution",
1422+id: "cmd-streamed-failure",
1423+command: "pnpm test extensions/codex",
1424+cwd: "/workspace",
1425+processId: null,
1426+source: "agent",
1427+status: "failed",
1428+commandActions: [],
1429+aggregatedOutput: null,
1430+exitCode: 1,
1431+durationMs: 42,
1432+},
1433+]),
1434+);
1435+1436+expect(projector.buildResult(buildEmptyToolTelemetry()).lastToolError).toEqual({
1437+toolName: "bash",
1438+meta: "run tests (workspace)",
1439+error: "fatal: missing fixture",
1440+mutatingAction: true,
1441+actionFingerprint: JSON.stringify({
1442+type: "commandExecution",
1443+command: "pnpm test extensions/codex",
1444+cwd: "/workspace",
1445+}),
1446+});
1447+});
1448+14091449it("does not duplicate native tool starts when the snapshot completes a started item", async () => {
14101450const onAgentEvent = vi.fn();
14111451const trajectoryRecorder = {
@@ -1609,6 +1649,121 @@ describe("CodexAppServerEventProjector", () => {
16091649toolCallId: "cmd-declined",
16101650},
16111651]);
1652+expect(projector.buildResult(buildEmptyToolTelemetry()).lastToolError).toEqual({
1653+toolName: "bash",
1654+meta: "run tests (workspace)",
1655+error: "codex native tool blocked",
1656+mutatingAction: true,
1657+actionFingerprint: JSON.stringify({
1658+type: "commandExecution",
1659+command: "pnpm test extensions/codex",
1660+cwd: "/workspace",
1661+}),
1662+});
1663+});
1664+1665+it("clears a recovered declined native tool error", async () => {
1666+const projector = await createProjector();
1667+1668+await projector.handleNotification(
1669+forCurrentTurn("item/completed", {
1670+item: {
1671+type: "commandExecution",
1672+id: "cmd-declined",
1673+command: "pnpm test extensions/codex",
1674+cwd: "/workspace",
1675+processId: null,
1676+source: "agent",
1677+status: "declined",
1678+commandActions: [],
1679+aggregatedOutput: null,
1680+exitCode: null,
1681+durationMs: 1,
1682+},
1683+}),
1684+);
1685+expect(projector.buildResult(buildEmptyToolTelemetry()).lastToolError).toEqual({
1686+toolName: "bash",
1687+meta: "run tests (workspace)",
1688+error: "codex native tool blocked",
1689+mutatingAction: true,
1690+actionFingerprint: JSON.stringify({
1691+type: "commandExecution",
1692+command: "pnpm test extensions/codex",
1693+cwd: "/workspace",
1694+}),
1695+});
1696+1697+await projector.handleNotification(
1698+forCurrentTurn("item/completed", {
1699+item: {
1700+type: "commandExecution",
1701+id: "cmd-recovered",
1702+command: "pnpm test extensions/codex",
1703+cwd: "/workspace",
1704+processId: null,
1705+source: "agent",
1706+status: "completed",
1707+commandActions: [],
1708+aggregatedOutput: "ok",
1709+exitCode: 0,
1710+durationMs: 42,
1711+},
1712+}),
1713+);
1714+1715+expect(projector.buildResult(buildEmptyToolTelemetry()).lastToolError).toBeUndefined();
1716+});
1717+1718+it("does not clear a declined native tool error with a different action", async () => {
1719+const projector = await createProjector();
1720+1721+await projector.handleNotification(
1722+forCurrentTurn("item/completed", {
1723+item: {
1724+type: "commandExecution",
1725+id: "cmd-declined",
1726+command: "pnpm test extensions/codex",
1727+cwd: "/workspace",
1728+processId: null,
1729+source: "agent",
1730+status: "declined",
1731+commandActions: [],
1732+aggregatedOutput: null,
1733+exitCode: null,
1734+durationMs: 1,
1735+},
1736+}),
1737+);
1738+await projector.handleNotification(
1739+forCurrentTurn("item/completed", {
1740+item: {
1741+type: "commandExecution",
1742+id: "cmd-unrelated-success",
1743+command: "pnpm test src/foo.test.ts",
1744+cwd: "/workspace",
1745+processId: null,
1746+source: "agent",
1747+status: "completed",
1748+commandActions: [],
1749+aggregatedOutput: "ok",
1750+exitCode: 0,
1751+durationMs: 42,
1752+},
1753+}),
1754+);
1755+1756+expect(projector.buildResult(buildEmptyToolTelemetry()).lastToolError).toEqual({
1757+toolName: "bash",
1758+meta: "run tests (workspace)",
1759+error: "codex native tool blocked",
1760+mutatingAction: true,
1761+actionFingerprint: JSON.stringify({
1762+type: "commandExecution",
1763+command: "pnpm test extensions/codex",
1764+cwd: "/workspace",
1765+}),
1766+});
16121767});
1613176816141769it("emits after_tool_call observations for Codex-native tool item completions", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。