Skip to content

Commit 0b6d33f

Browse files
b1rdmaniaclaude
andcommitted
fix: error message now reports actual timeout that fired
Track timeoutReason ('idle' | 'absolute') and use the corresponding duration in the error string and log, instead of always reporting configTimeout regardless of which timer fired. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a7cde58 commit 0b6d33f

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/container-runner.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ export async function runContainerAgent(
358358
});
359359

360360
let timedOut = false;
361+
let timeoutReason: 'idle' | 'absolute' | null = null;
361362
let hadStreamingOutput = false;
362363
const configTimeout = group.containerConfig?.timeout || CONTAINER_TIMEOUT;
363364
const idleTimeoutMs = Math.min(
@@ -368,6 +369,7 @@ export async function runContainerAgent(
368369

369370
const killOnTimeout = (reason: 'idle' | 'absolute') => {
370371
timedOut = true;
372+
timeoutReason = reason;
371373
logger.error(
372374
{ group: group.name, processName, reason },
373375
reason === 'idle'
@@ -414,10 +416,17 @@ export async function runContainerAgent(
414416
].join('\n'),
415417
);
416418

419+
const timeoutMs =
420+
timeoutReason === 'idle' ? idleTimeoutMs : absoluteTimeoutMs;
421+
const timeoutLabel =
422+
timeoutReason === 'idle'
423+
? `idle timeout (${idleTimeoutMs}ms no stdout)`
424+
: `absolute timeout (${absoluteTimeoutMs}ms ceiling)`;
425+
417426
if (hadStreamingOutput) {
418427
logger.info(
419-
{ group: group.name, processName, duration, code },
420-
'Agent timed out after output (idle cleanup)',
428+
{ group: group.name, processName, duration, code, timeoutReason },
429+
`Agent timed out after output (${timeoutLabel})`,
421430
);
422431
outputChain.then(() => {
423432
resolve({
@@ -430,14 +439,14 @@ export async function runContainerAgent(
430439
}
431440

432441
logger.error(
433-
{ group: group.name, processName, duration, code },
434-
'Agent timed out with no output',
442+
{ group: group.name, processName, duration, code, timeoutReason },
443+
`Agent timed out with no output (${timeoutLabel})`,
435444
);
436445

437446
resolve({
438447
status: 'error',
439448
result: null,
440-
error: `Agent timed out after ${configTimeout}ms`,
449+
error: `Agent timed out after ${timeoutMs}ms (${timeoutLabel})`,
441450
});
442451
return;
443452
}

0 commit comments

Comments
 (0)