From ec56330d084b5c285bf2e4adc72fbeffa7fee1db Mon Sep 17 00:00:00 2001 From: Jeremy McSpadden <211150+jeremymcs@users.noreply.github.com> Date: Tue, 18 Aug 2026 10:12:31 -0500 Subject: [PATCH] fix: report issue work timeout cause --- server/issueWorkAgent.test.ts | 52 +++++++++++++++++++++++++++++++++++ server/issueWorkAgent.ts | 4 +-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/server/issueWorkAgent.test.ts b/server/issueWorkAgent.test.ts index 2daa757..366ccf0 100644 --- a/server/issueWorkAgent.test.ts +++ b/server/issueWorkAgent.test.ts @@ -156,6 +156,58 @@ test("runIssueWorkRepair commits, pushes, and verifies the issue branch", async assert.match(extractIssueWorkSummary("ISSUE_WORK_SUMMARY: fixed the toggle"), /fixed the toggle/); }); +test("runIssueWorkRepair reports a Codex timeout instead of a models cache warning", async () => { + const result = await runIssueWorkRepair({ + repo: "acme/widgets", + issueNumber: 17, + issueTitle: "Fix the toggle", + issueUrl: "https://github.com/acme/widgets/issues/17", + issueBody: "The toggle is stuck", + labels: ["bug"], + author: "alice", + baseBranch: "main", + repoCloneUrl: "https://github.com/acme/widgets.git", + agent: "codex", + dependencies: { + preparePrWorktree: async () => ({ + repoCacheDir: "/tmp/repo-cache", + worktreePath: "/tmp/worktree", + }), + removePrWorktree: async () => undefined, + applyFixesWithAgent: async () => ({ + code: 124, + stdout: "", + stderr: [ + "Reading additional input from stdin...", + "ERROR codex_models_manager::cache: failed to load models cache: missing field `base_instructions` at line 95 column 5", + "OpenAI Codex v0.146.1", + "Command timed out after 5400000ms", + ].join("\n"), + timedOut: true, + }), + readFile: async () => { + throw Object.assign(new Error("missing"), { code: "ENOENT" }); + }, + runCommand: async (command: string, args: string[]) => { + if (command !== "git") { + throw new Error(`Unexpected command: ${command}`); + } + if (args[2] === "checkout" && args[3] === "-b") { + return { stdout: "", stderr: "", code: 0 }; + } + if (args[0] === "config" && args[1] === "--get") { + return { stdout: "set\n", stderr: "", code: 0 }; + } + throw new Error(`Unexpected git args: ${args.join(" ")}`); + }, + }, + }); + + assert.equal(result.accepted, false); + assert.equal(result.rejectionReason, "agent failed (124): Command timed out after 5400000ms"); + assert.doesNotMatch(result.rejectionReason ?? "", /models cache/i); +}); + const SAMPLE_SUBTASKS: IssueSubtask[] = [ { id: "bug-1", title: "Verifier exit code inverted", summary: "Treats 0 as the only pass.", status: "pending" }, { id: "bug-2", title: "Preference overrides plan", summary: "Falls back to preference silently.", status: "pending" }, diff --git a/server/issueWorkAgent.ts b/server/issueWorkAgent.ts index 4bf4ed5..0d7ff41 100644 --- a/server/issueWorkAgent.ts +++ b/server/issueWorkAgent.ts @@ -1,6 +1,6 @@ import { readFile } from "node:fs/promises"; import type { AgentRuntimeSettings, CodingAgent, CommandResult } from "./agentRunner"; -import { applyFixesWithAgent, runCommand, summarizeCommandResult } from "./agentRunner"; +import { applyFixesWithAgent, runCommand, summarizeAgentCommandFailure } from "./agentRunner"; import { preparePrWorktree, removePrWorktree } from "./repoWorkspace"; import type { IssueSubtask, IssueSubtaskStatus } from "@shared/schema"; import path from "node:path"; @@ -490,7 +490,7 @@ export async function runIssueWorkRepair( if (agentResult.code !== 0) { return { accepted: false, - rejectionReason: summarizeCommandResult(agentResult, `agent failed (${agentResult.code})`), + rejectionReason: `agent failed (${agentResult.code}): ${summarizeAgentCommandFailure(agentResult)}`, summary: extractIssueWorkSummary(agentResult.stdout), fixBranch, agentResult,