gpt-5.4 on codex cli is very reluctant, and even resistant, to reading long files

Resolved 💬 2 comments Opened Mar 24, 2026 by unbyte Closed Mar 24, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What issue are you seeing?

When using gpt‑5.4, if I force it to read an entire markdown doc (around 1,000 lines), it will occasionally run wc -l to check the line count, but every time it only reads the first 220 lines. Even if I continue asking it in follow-up turns to read the full doc, it either checks the line count with wc -l and then answers without reading anything, or insists that the 220 lines it already read are the complete file.

Switching back to gpt-5.3-codex, even without repeatedly asking it to read the entire doc, it can tell the file is long and keeps reading in multiple passes until it has consumed the full file content before answering.

What steps can reproduce the bug?

Unless I’m just extremely unlucky and happened to hit a bad case in ~10 repeated conversations, this should be reproducible by giving gpt-5.4 a markdown file longer than 1,000 lines and discussing its contents with it, even when you explicitly require it to read the entire file.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

2 Comments

etraut-openai contributor · 5 months ago

Thanks for the bug report. We'll share the feedback with the team responsible for training our codex models. If you see other model behavior that you'd like to report, please use the /feedback command. That will provide us with additional details including logs and conversation text.

raye-deng · 5 months ago

This is a textbook example of a problem that's much broader than file reading — it's about agent self-reporting being structurally unreliable.

The model says "I read it" when it only read 220 lines. Swap "read" for "tested" or "verified" and you get the same pattern:

  • Agent says: "I ran the tests and they all pass" → actually skipped edge cases
  • Agent says: "I verified the migration is safe" → only checked the happy path
  • Agent says: "I confirmed the dependency exists on npm" → hallucinated the confirmation

In our CI scanner we see this constantly — AI-generated code where the agent's self-reported verification doesn't match reality. The fix we settled on is to never trust the agent's own assessment and instead run deterministic checks independently:

  1. Import validation against the actual npm/PyPI registry (catches hallucinated packages)
  2. Deprecated API detection via runtime introspection (catches stale API usage the agent "confirmed" works)
  3. Cross-file reference integrity checks (catches inconsistencies the agent "verified" were consistent)

GPT-5.4 being reluctant to read long files is a model behavior issue, but the deeper risk is that it reports having read the file when it hasn't. That's the failure mode that leads to production incidents.

npx @opencodereview/cli scan . --sla L1 — if you want to see what independent verification looks like on your codebase.