Skip to content

Commit 2498868

Browse files
nodeeeeeeclaude
andcommitted
Show tail of codex stderr on failure, not head
When `codex exec` fails, the real error (quota, auth, model-not- supported, 4xx from the provider) is at the *end* of stderr. The head is startup noise — skill loader warnings, session preamble — which just hides the actual cause. Truncating from the right means the RuntimeError message surfaces the line that explains the exit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9c48d6d commit 2498868

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

note_generation.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ def _call(model: str, system: str, user: str, max_tokens: int,
593593
# We run non-interactively, read-only sandbox, outside a git repo, and
594594
# capture only the agent's final message via `-o <file>` so we don't
595595
# have to parse the streaming event log on stdout.
596+
# The caller's ~/.codex/config.toml default (e.g. gpt-5.2-codex) is
597+
# often not available on a ChatGPT-plan login, so we override to a
598+
# model that is — gpt-5.4 by default; set AUTONOTE_CODEX_MODEL to
599+
# pick a different one (e.g. gpt-5.5, gpt-5.4-mini).
596600
if _provider(model) == "codex-cli":
597601
import subprocess as _sp
598602
import tempfile as _tf
@@ -601,8 +605,10 @@ def _call(model: str, system: str, user: str, max_tokens: int,
601605
_os2.close(out_fd)
602606
try:
603607
prompt_text = f"{system}\n\n{user}" if system else user
608+
codex_model = _os2.environ.get("AUTONOTE_CODEX_MODEL", "gpt-5.4")
604609
cmd = [
605610
"codex", "exec",
611+
"-m", codex_model,
606612
"--skip-git-repo-check",
607613
"-s", "read-only",
608614
"-o", out_file,
@@ -620,8 +626,12 @@ def _call(model: str, system: str, user: str, max_tokens: int,
620626
_truncated.append(False) # CLI handles its own limits
621627
if result.returncode != 0 and not content:
622628
err = (result.stderr or result.stdout or "").strip()
629+
# Surface the real failure at the *tail* of stderr (quota,
630+
# auth, 400s from the provider). The head is usually just
631+
# skill-loader warnings and the session preamble.
632+
tail = err[-600:] if len(err) > 600 else err
623633
raise RuntimeError(
624-
f"codex exec failed (code {result.returncode}): {err[:500]}"
634+
f"codex exec failed (code {result.returncode}): {tail}"
625635
)
626636
return content
627637
finally:

0 commit comments

Comments
 (0)