openai / openai/codex

Codex repeatedly generates broken Markdown when nested code fences are requested

Open
#44,407 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug extension model-behavior windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of the IDE extension are you using?

26.901.22334

What subscription do you have?

chatgpt pro

Which IDE are you using?

openai.chatgpt

What platform is your computer?

Windows

What issue are you seeing?

When Codex is asked to provide copy-ready Markdown containing fenced code examples, it may use the same fence length for the outer and inner blocks.

The inner fence then closes the outer block prematurely. The remaining content is rendered outside the intended Markdown block.

The issue also occurred immediately after Codex tried to correct its first broken response:

  • First response: three backticks outside and inside
  • Corrected response: four backticks outside and inside
  • Both responses broke at the nested fence
What steps can reproduce the bug?
  1. Ask Codex to output a complete document as copy-ready Markdown.

  2. Require fenced code examples inside the document.

  3. Example prompt:

    Give me the complete text as Markdown. Include PowerShell and text code blocks.
    
  4. Codex wraps the document in a fenced block.

  5. Codex uses an inner fence of the same length.

  6. The outer block ends prematurely.

What is the expected behavior?

Codex should generate valid, copy-ready Markdown.

It should ensure that the outer fence is longer than every fence contained in the document. Alternatively, it could use tildes for the outer fence:

~~~~md
```powershell
$env:DEBUG
Additional information

Environment:

  • Windows
  • Visual Studio Code
  • Extension ID: openai.chatgpt
  • Extension version: 26.901.22334

The Markdown renderer appears to behave correctly. The generated delimiter structure itself is invalid.

Impact:

  • Broken rendering
  • Content cannot be copied as one Markdown block
  • Manual correction is required
  • The attempted correction can reproduce the same mistake with a longer fence

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or failing test is identified in the report. Start by reproducing the issue with the supplied prompt and locating the Markdown-generation path; done means nested fenced examples remain inside one valid, copy-ready outer block, including after a correction request.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown
Domain
ai
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.