Skip to content

Commit 761cb4c

Browse files
committed
fix(cursor): keep failure guidance for a failed exec wrapper
Follow-up review finding (CodeRabbit) on 60537f0, and a regression I introduced in the previous commit rather than a pre-existing one. Routing Cursor's Codex-exec branch through `isEmptyOrFailedExecWrapper` restored the old matching, but the branch still returned `EMPTY_EXEC_OUTPUT_MESSAGE` unconditionally. A `Script failed` wrapper therefore reported that execution succeeded with empty output, erasing the only failure signal — the same defect just fixed on the Kiro path, reintroduced one layer up. It classifies the text by wrapper now; Cursor's `isError` policy is untouched and still owned by the Computer Use branch above it. The re-posted Codex P2 about `completionMode` staying `required` was checked against current code and is already addressed at `kiro.ts:513-515`: a trailing delivered answer resolves the mode to `disabled`, so the completion tool and its instructions are never advertised and the `needsFallback` retry path cannot be entered. The comment it cites sits at the acknowledgement, which is the second half of that fix. Verification: `bun x tsc --noEmit` clean; 204 tests pass across the same five suites. The new Cursor assertion was driven red by reverting the fix.
1 parent 60537f0 commit 761cb4c

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎src/adapters/cursor/tool-result-normalize.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import {
1313
EMPTY_EXEC_OUTPUT_MESSAGE,
1414
EMPTY_EXEC_OUTPUT_REGEX,
15+
FAILED_EXEC_OUTPUT_MESSAGE,
1516
FAILED_EXEC_OUTPUT_REGEX,
1617
isCodexExecBridgeTool,
1718
} from "../exec-tool-result-normalize";
@@ -95,7 +96,10 @@ export function normalizeCursorToolResultText(
9596
}
9697
if (isCodexExecBridgeTool(options.toolName, options.toolNamespace) && isEmptyOrFailedExecWrapper(text.trim())) {
9798
return {
98-
text: EMPTY_EXEC_OUTPUT_MESSAGE,
99+
// A `Script failed` wrapper is empty but NOT a success: reporting it as an empty success
100+
// would erase the only failure signal. Text classification stays separate from Cursor's
101+
// isError policy, which the Computer Use branch above owns.
102+
text: FAILED_EXEC_OUTPUT_REGEX.test(text.trim()) ? FAILED_EXEC_OUTPUT_MESSAGE : EMPTY_EXEC_OUTPUT_MESSAGE,
99103
isError: false,
100104
changed: true,
101105
};

‎tests/cursor-exec-empty-result.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ describe("codex exec bridge empty-result normalization (devlog 260826 gap-7)", (
2929
}
3030
});
3131

32+
// A failed wrapper is empty but not a success: reporting it as an empty success would erase the
33+
// only failure signal. Reachable with isError: false through Responses history.
34+
test("a failed exec wrapper keeps failure guidance, not empty-success text", () => {
35+
const out = normalizeCursorToolResultText("Script failed\nWall time 0.1 seconds\nOutput:\n", { toolName: "exec", isError: false });
36+
expect(out.changed).toBe(true);
37+
expect(out.text).toContain("exec failed");
38+
expect(out.text).not.toContain("NOT lost context");
39+
expect(out.text).not.toContain("Do not re-run");
40+
});
41+
3242
test("non-empty exec output passes through byte-identical", () => {
3343
const out = normalizeCursorToolResultText("Output:\nhello", { toolName: "exec" });
3444
expect(out.changed).toBe(false);

0 commit comments

Comments
 (0)