From 030b1cc447eea2da5661257f6e5dbe768c899551 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Mon, 1 Dec 2025 11:49:33 -0500 Subject: [PATCH] Use only stderr for code auto-fix error detection Update code execution error detection to use stderr exclusively instead of checking both stdout and stderr. This aligns with the Unsandbox API's proper stream separation where: - stdout is for program output - stderr is for errors/warnings Changes: - Remove stdout from error detection logic - Only trigger auto-fix when exit_code != 0 AND stderr is non-empty - Send only stderr to /api/fix-code endpoint This prevents false positives where stdout contains normal output that was previously being treated as error content. --- templates/chat.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/templates/chat.html b/templates/chat.html index 468448d..2488483 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -1594,11 +1594,9 @@ async function executeCodeBlock(code, blockElement, playButton) { // Check if execution failed and attempt auto-fix const exitCode = job.exit_code; const stderr = job.stderr || ''; - const stdout = job.stdout || ''; - // Error messages can be in either stderr OR stdout (Python puts tracebacks in stdout) - const errorOutput = stderr.trim() || stdout.trim(); - const shouldAutoFix = exitCode !== 0 && errorOutput !== ''; + // Only use stderr for error detection (stdout/stderr properly separated now) + const shouldAutoFix = exitCode !== 0 && stderr.trim() !== ''; // Track attempts per code block (store in resultsContainer dataset) if (!resultsContainer.dataset.fixAttempts) { @@ -1629,7 +1627,7 @@ async function executeCodeBlock(code, blockElement, playButton) { body: JSON.stringify({ code: code, language: language, - stderr: errorOutput, // Send combined error output (stderr or stdout) + stderr: stderr, // Send only stderr (properly separated now) exit_code: exitCode, attempt: currentAttempts + 1 })