{"slug": "my-fight-with-a-ghost-in-the-machine-a-gpt-5-codex-review", "title": "My Fight With a Ghost in the Machine: A GPT-5 Codex Review", "summary": "A developer reports that OpenAI's GPT-5 Codex preview, while faster and more accurate than GPT-4o, introduces a higher rate of type-safety errors due to what the author calls 'architectural arrogance' — the model assumes the compiler shares its understanding of implicit types. In a benchmark, GPT-5 Codex achieved 94% logic accuracy (up from 82%) and 0.4s per block boilerplate speed (down from 1.2s), but type-safety errors rose to 6 per 10 prompts from 4. The fix required explicit discriminated unions rather than relying on the model's inferred types.", "body_md": "# My Fight With a Ghost in the Machine: A GPT-5 Codex Review\n\n`any`\n\ndespite my strict configuration. I was testing a bleeding-edge implementation of a state machine for a real-time dashboard, utilizing what many are calling the \"Codex\" capabilities of the next-gen GPT-5 iterations.The code looked perfect. The logic was sound. But the compiler was screaming.\n\nThe specific error that kept popping up in my terminal was:`TS2367: This condition will always return 'false' since the types 'UserState' and 'AdminState' overlap.`\n\nThe wild part? GPT-5 Codex had written the types. It had written the logic. And then it told me, with absolute confidence, that the types *didn't* overlap.\n\n## The Diagnosis: Over-confidence in Type Inference\n\nI tried the usual dance. I prompted the model to \"fix the type overlap.\" It gave me the same code back but shifted a few brackets. Still failed. I tried telling it I was using TypeScript 5.4. It apologized and gave me a solution that used `as unknown as T`\n\n, which is basically the \"I give up\" of the typing world.\n\nI didn't want a hack. I wanted a solution.\n\nThe bottleneck wasn't the model's ability to write syntax—it's a god among men at syntax. The bottleneck was a subtle misunderstanding of how the model handles discriminated unions when the discriminator property is inferred rather than explicit. The model was treating the object shapes as distinct in its internal latent space, but the TypeScript compiler saw them as structurally identical because I'd omitted the explicit tags.\n\nI realized I was fighting a ghost. The model \"knew\" what the objects were, but it forgot that the compiler doesn't have a psychic link to the LLM's intent.\n\n## The Fix: Explicit Tagging and a Prompt Pivot\n\nI stopped asking it to \"fix the error\" and started asking it to \"audit the structural uniqueness of the interfaces.\" That small shift in framing—from fixing a bug to auditing a structure—changed everything.\n\nThe fix was simple:\n\n```\n// Before: Implicitly different (The \"Ghost\" version)\ninterface UserState { name: string; role: 'user'; }\ninterface AdminState { name: string; role: 'admin'; }\n\n// After: Explicitly discriminated (The Fix)\ntype State = \n  | { type: 'USER'; data: UserState } \n  | { type: 'ADMIN'; data: AdminState };\n```\n\nOnce I forced the model to implement a rigid `type`\n\ntag, the \"overlap\" error vanished instantly.\n\n## How This Shapes My GPT-5 Codex Review\n\nIf you're looking for a \"this tool does everything\" review, go read a marketing blog. Here is the reality: GPT-5 Codex (and its current iterations) is frighteningly fast, but it suffers from a new kind of \"hallucination\"—architectural arrogance. It assumes the environment is as smart as the model.\n\nI ran a quick benchmark on three complex refactors last week. Here is how it stacked up against the previous generation (GPT-4o/Codex legacy):\n\n| Metric | GPT-4o (Legacy) | GPT-5 Codex (Preview) | Delta |\n\n| :--- | :--- | :--- | :--- |\n\n| Logic Accuracy | 82% | 94% | +12% |\n\n| Boilerplate Speed | 1.2s / block | 0.4s / block | -0.8s |\n\n| Type-Safety Errors | 4 / 10 prompts | 6 / 10 prompts | +2 (Worse) |\n\n| Context Window Drift | Noticeable after 8k | Minimal until 32k | Massive improvement |\n\nIt is significantly better at understanding the \"big picture\" of a codebase, but it's more likely to skip the boring, explicit details that actually make code compile. It's like hiring a brilliant senior architect who forgets to tell the contractors where the plumbing goes.\n\n## The Workflow Gap\n\nThe problem is that most people use these models in a vacuum. I spent a long time just copying and pasting snippets until I started diving into [AI Coding](/en/category/ai-coding/) communities where people actually share their `.cursorrules`\n\nor system prompts.\n\nThe secret isn't the model; it's the guardrails you build around it. I’ve found that if I don't explicitly tell the model \"Do not use type assertions (as any/unknown) unless absolutely necessary,\" it will take the path of least resistance every time.\n\nTo get this thing to actually perform, I had to stop treating it like a magic box and start treating it like a junior dev with a PhD. It knows the theory, but it has zero common sense regarding the actual build process.\n\n## Moving Beyond the Chat Box\n\nThe real power happens when you stop using the web interface. I've been integrating these models via [MCP](/en/tags/mcp/) (Model Context Protocol) to let the AI actually see my file structure. When the model can see that `UserState`\n\nis defined in `types/user.ts`\n\nand `AdminState`\n\nis in `types/admin.ts`\n\n, the \"overlap\" errors drop significantly because it's no longer guessing the context from a snippet.\n\nIf you're struggling with the same \"hallucinated logic\" I hit, check out the [Resources](/en/category/resources/) section of the community. There are a few specific prompt templates for \"Structural Auditing\" that stop the model from taking shortcuts.\n\n## Why You Need a Community (And Why I Joined PromptCube)\n\nCoding with AI is an isolating experience until you hit a bug that doesn't exist in any official documentation. I spent two days thinking my TypeScript installation was corrupted before I found a thread on PromptCube where someone else had the exact same \"structural overlap\" issue with the new Codex models.\n\nThe value of a community like PromptCube isn't just sharing prompts—it's the collective debugging. We're all basically beta-testing the future of software engineering in real-time. One person discovers that a specific version of a library clashes with the model's training data, posts it, and suddenly a thousand of us save ten hours of frustration.\n\nJoining is straightforward: you just sign up and start contributing your fails. The \"fails\" are actually more valuable than the wins. A \"it worked perfectly\" post tells me nothing. A \"here is the weird error I got and the prompt that finally killed it\" post is gold.\n\n## The Verdict on the Tech\n\nIs GPT-5 Codex a replacement for a developer? No. But it is a replacement for the *way* we develop.\n\nWe are moving from \"writing code\" to \"reviewing generated logic.\" The skill shift is massive. You no longer need to remember the exact syntax for a complex Regex or a obscure CSS Grid property; you need to be an expert at spotting when the AI is lying to you about a type overlap.\n\nThe model is a powerhouse, but it's a volatile one. It'll write 200 lines of perfect Python in three seconds, then trip over a semicolon.\n\nDepending on which [AI Models](/en/category/ai-models/) you prefer for your stack, the experience varies, but the Codex-style logic is consistently the top performer for heavy lifting. Just don't trust it with your types without a second pair of eyes.\n\nMy advice? Stop trusting the first \"fix\" it gives you. Challenge it. Tell it the fix failed. Demand an audit. That's where the actual efficiency gains are.\n\n[Next Hugging Face CEO on AI Transparency →](/en/news/3849/)\n\n## All Replies （0）\n\nNo replies yet — be the first!", "url": "https://wpnews.pro/news/my-fight-with-a-ghost-in-the-machine-a-gpt-5-codex-review", "canonical_source": "https://promptcube3.com/en/threads/3861/", "published_at": "2026-07-26 21:50:59+00:00", "updated_at": "2026-07-26 22:07:58.988698+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "developer-tools"], "entities": ["OpenAI", "GPT-5 Codex", "GPT-4o", "TypeScript"], "alternates": {"html": "https://wpnews.pro/news/my-fight-with-a-ghost-in-the-machine-a-gpt-5-codex-review", "markdown": "https://wpnews.pro/news/my-fight-with-a-ghost-in-the-machine-a-gpt-5-codex-review.md", "text": "https://wpnews.pro/news/my-fight-with-a-ghost-in-the-machine-a-gpt-5-codex-review.txt", "jsonld": "https://wpnews.pro/news/my-fight-with-a-ghost-in-the-machine-a-gpt-5-codex-review.jsonld"}}