fix: improve container error logging to include full stdout/stderr

Always log detailed input/output/stderr on error (not just in verbose
mode), and stop truncating stderr/stdout in structured log fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gavriel Cohen
2026-02-07 00:17:46 +02:00
parent 8dd27bc58d
commit 675ed30ba0

View File

@@ -339,7 +339,9 @@ export async function runContainerAgent(
``, ``,
]; ];
if (isVerbose) { const isError = code !== 0;
if (isVerbose || isError) {
logLines.push( logLines.push(
`=== Input ===`, `=== Input ===`,
JSON.stringify(input, null, 2), JSON.stringify(input, null, 2),
@@ -373,14 +375,6 @@ export async function runContainerAgent(
.join('\n'), .join('\n'),
``, ``,
); );
if (code !== 0) {
logLines.push(
`=== Stderr (last 500 chars) ===`,
stderr.slice(-500),
``,
);
}
} }
fs.writeFileSync(logFile, logLines.join('\n')); fs.writeFileSync(logFile, logLines.join('\n'));
@@ -392,7 +386,8 @@ export async function runContainerAgent(
group: group.name, group: group.name,
code, code,
duration, duration,
stderr: stderr.slice(-500), stderr,
stdout,
logFile, logFile,
}, },
'Container exited with error', 'Container exited with error',
@@ -439,7 +434,8 @@ export async function runContainerAgent(
logger.error( logger.error(
{ {
group: group.name, group: group.name,
stdout: stdout.slice(-500), stdout,
stderr,
error: err, error: err,
}, },
'Failed to parse container output', 'Failed to parse container output',