@devries-cameron20 / t3code-1 / commits / bb9658d3a7
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

perf(shared): command output failure scan rejects clean output in one pass (#26935)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Hieu Le committed Nov 13, 2026 at 03:23 UTC bb9658d3a76b315a09e4d673b24bd1751797c446
2 files changed +14 -6
packages/shared/src/toolOutput.test.ts
+4
@@ -156,6 +156,7 @@ describe("toolOutputIndicatesFailure", () => {
156 "<exited with exit code 2>",
157 "Exited with exit code 1",
158 "exit code: 127",
159 + "clean exit first, then ExIt CoDe: 3",
160 ])
161 expect(toolOutputIndicatesFailure(text)).toBe(true);
162 });
@@ -167,6 +168,9 @@ describe("toolOutputIndicatesFailure", () => {
168 "Exited with exit code 0",
169 "cannot find path",
170 "is not recognized",
171 + "exit",
172 + "not found",
173 + "the path cannot be found",
174 ]) {
175 expect(toolOutputIndicatesFailure(text)).toBe(false);
176 }
packages/shared/src/toolOutput.ts
+10 -6
@@ -232,17 +232,21 @@ export function mcpAppFromToolItem(item: {
232 : undefined;
233 }
234
235 +// A superset of every needle below, so most outputs are rejected by this single scan.
236 +const FAILURE_HINT =
237 + /enoent|no such|no files found|not found|commandnotfound|not recognized|cannot (?:find path|be found)|exit/i;
238 +
239 /** Some providers report completion even when command output describes a failure. */
240 export function toolOutputIndicatesFailure(text: string): boolean {
241 return (
238 - /file not found|no files found|enoent|no such file|commandnotfoundexception|command not found|is not recognized as the name of a cmdlet|a parameter cannot be found that matches parameter name/i.test(
242 + FAILURE_HINT.test(text) &&
243 + (/file not found|no files found|enoent|no such file|commandnotfoundexception|command not found|is not recognized as the name of a cmdlet|a parameter cannot be found that matches parameter name/i.test(
244 text,
245 ) ||
241 - (/cannot find path/i.test(text) && /because it does not exist/i.test(text)) ||
242 - (/is not recognized/i.test(text) && /the term '/i.test(text)) ||
243 - /<exited with exit code\s+[1-9]\d*\s*>/i.test(text) ||
244 - /exit(?:ed)? with exit code\s+[1-9]\d*/i.test(text) ||
245 - /exit code\s*[:\s]\s*[1-9]\d*\b/i.test(text)
246 + (/cannot find path/i.test(text) && /because it does not exist/i.test(text)) ||
247 + (/is not recognized/i.test(text) && /the term '/i.test(text)) ||
248 + /exit(?:ed)? with exit code\s+[1-9]\d*/i.test(text) ||
249 + /exit code\s*[:\s]\s*[1-9]\d*\b/i.test(text))
250 );
251 }
252