affaan-m/ECC · error · Error
Codex returned no final response
Error message
Codex returned no final response: ${error.message} What it means
After a successful Codex exit, the library reads the final response from an output file Codex was instructed to write in the temp directory. If reading that file fails (it does not exist, is unreadable, or was already cleaned up), the underlying fs error is wrapped as 'Codex returned no final response: <error.message>'.
Solutions
- Check the wrapped error.message: ENOENT means Codex never wrote the file; EACCES means permissions.
- Confirm the installed Codex CLI version supports the output-file invocation this script uses; align versions (`npm install -g @openai/codex@<pinned>`).
- Run Codex manually with the same flags to see where it actually writes the response.
- Ensure TMPDIR points to a writable directory if the temp location is customized.
- Update the script if a newer Codex version changed its output contract.
Example fix
// before $ codex --old-flag out.txt # CLI silently ignores output file // after npm install -g @openai/codex@2 # version matching script's output-file contract $ node review-with-codex.js # file now created and read successfully
Defensive patterns
Strategy: fallback
Try / catch
try {
return runReview(opts);
} catch (e) {
if (e.message.startsWith('Codex returned no final response')) {
// fall back to a different council provider or retry with a pinned CLI version
return otherProvider.review(opts);
}
throw e;
} Prevention
- Pin the Codex CLI version; output-file behavior changes across releases are the top cause.
- Smoke-test the output-file contract with a trivial prompt after any CLI upgrade.
- Ensure TMPDIR is writable and not aggressively cleaned by other tooling.
When it happens
Trigger: The codex CLI exits 0 but never created outputFile — e.g. the CLI version ignores the output-file flag, wrote it to a different location, or crashed after exit-code reporting — so readFile(outputFile) throws ENOENT/EACCES.
Common situations: Codex CLI upgraded/downgraded and changed its output-file behavior; wrong working directory assumptions; read-only or oddly-permissioned temp dir; antivirus quarantining the temp output file.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Agents directory not found
- Codex returned an empty final response
- unsupported Codex version
- --all-harnesses and --harness are mutually exclusive.
- all overlays must be readable local files
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/e90e7260846e5116.
Report an issue: GitHub.
Appendix: source
Thrown at skills/council-multi-model/scripts/review-with-codex.js:226
maxBuffer: 1024 * 1024,
windowsHide: true,
});
if (result.error) {
if (result.error.code === 'ETIMEDOUT') throw new Error('Codex review timed out');
if (result.error.code === 'ENOENT') throw new Error('Codex CLI is not installed');
throw new Error(`Codex invocation failed: ${result.error.message}`);
}
if (result.status !== 0) {
const detail = (result.stderr || '').trim().split('\n').slice(-1)[0];
throw new Error(`Codex review failed${detail ? `: ${detail}` : ''}`);
}
let text;
try {
text = readFile(outputFile, 'utf8').trim();
} catch (error) {
throw new Error(`Codex returned no final response: ${error.message}`);
}
if (!text) throw new Error('Codex returned an empty final response');
return `${providerLabel(options.hostProvider)}\n${text}`;
} finally {
remove(tempDir, { recursive: true, force: true });
}
}
function runStdinReview(options, dependencies = {}) {
const stdin = dependencies.stdin || process.stdin;
const stdout = dependencies.stdout || process.stdout;
const stderr = dependencies.stderr || process.stderr;
const review = dependencies.runReview || runReview;
const setExitCode = dependencies.setExitCode || ((code) => { process.exitCode = code; });
const chunks = [];
let promptBytes = 0;
let promptOverflow = false;
stdin.setEncoding('utf8');View on GitHub (pinned to 8321021c54)