Thread run error codes into interrupt labels

This commit is contained in:
Dotta committed 2026-06-09 23:06:49 +00:00
1 parent aa80f2666e
commit 3479370ec7
4 files changed
+40 -3

No files matched your search

+1
View File
@@ -387,6 +387,7 @@ export function activityService(db: Db) {
finishedAt: heartbeatRuns.finishedAt,
createdAt: heartbeatRuns.createdAt,
invocationSource: heartbeatRuns.invocationSource,
errorCode: heartbeatRuns.errorCode,
usageJson: summarizedUsageJson,
resultJson: summarizedResultJson,
logBytes: heartbeatRuns.logBytes,
+1
View File
@@ -12,6 +12,7 @@ export interface RunForIssue {
finishedAt: string | null;
createdAt: string;
invocationSource: string;
errorCode?: string | null;
usageJson: Record<string, unknown> | null;
resultJson: Record<string, unknown> | null;
logBytes?: number | null;
+33
View File
@@ -947,6 +947,39 @@ describe("buildIssueChatMessages", () => {
});
});
it("labels error-code-only operator interruptions as interrupted by board", () => {
const messages = buildIssueChatMessages({
comments: [],
timelineEvents: [],
linkedRuns: [
{
runId: "run-interrupted",
status: "cancelled",
agentId: "agent-1",
agentName: "CodexCoder",
createdAt: new Date("2026-04-06T12:01:00.000Z"),
startedAt: new Date("2026-04-06T12:01:00.000Z"),
finishedAt: new Date("2026-04-06T12:02:00.000Z"),
errorCode: "operator_interrupted",
resultJson: null,
},
],
liveRuns: [],
transcriptsByRunId: new Map([
["run-interrupted", [{ kind: "assistant", ts: "2026-04-06T12:01:05.000Z", text: "Working on it." }]],
]),
hasOutputForRun: (runId) => runId === "run-interrupted",
currentUserId: "user-1",
});
expect(messages).toHaveLength(1);
expect(messages[0]?.metadata.custom).toMatchObject({
chainOfThoughtLabel: "Interrupted by board after 1 minute",
runOperatorInterrupted: true,
runStatus: "cancelled",
});
});
it("can keep succeeded runs without transcript output for embedded run feeds", () => {
const messages = buildIssueChatMessages({
comments: [],
+5 -3
View File
@@ -46,6 +46,7 @@ export interface IssueChatLinkedRun {
finishedAt?: Date | string | null;
hasStoredOutput?: boolean;
logBytes?: number | null;
errorCode?: string | null;
resultJson?: Record<string, unknown> | null;
}
@@ -596,6 +597,7 @@ function runDurationLabel(run: {
createdAt: Date | string;
startedAt: Date | string | null;
finishedAt?: Date | string | null;
errorCode?: string | null;
resultJson?: Record<string, unknown> | null;
}) {
const start = run.startedAt ?? run.createdAt;
@@ -612,7 +614,7 @@ function runDurationLabel(run: {
case "timed_out":
return durationText ? `Timed out after ${durationText}` : "Run timed out";
case "cancelled":
if (isOperatorInterruptedRun(run.resultJson)) {
if (isOperatorInterruptedRun(run.resultJson, run.errorCode)) {
return durationText ? `Interrupted by board after ${durationText}` : "Interrupted by board";
}
if (stopReason === "paused") {
@@ -643,7 +645,7 @@ function createHistoricalRunMessage(run: IssueChatLinkedRun, agentMap?: Map<stri
runAgentId: run.agentId,
runAgentName: agentName,
runStatus: run.status,
runOperatorInterrupted: isOperatorInterruptedRun(run.resultJson),
runOperatorInterrupted: isOperatorInterruptedRun(run.resultJson, run.errorCode),
},
},
};
@@ -680,7 +682,7 @@ function createHistoricalTranscriptMessage(args: {
runAgentId: run.agentId,
runAgentName: agentName,
runStatus: run.status,
runOperatorInterrupted: isOperatorInterruptedRun(run.resultJson),
runOperatorInterrupted: isOperatorInterruptedRun(run.resultJson, run.errorCode),
notices,
waitingText,
chainOfThoughtLabel: runDurationLabel(run),