Markdown file woes

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Summary

Markdown files created or modified by AI agents (using the write tool OR shell commands executed by agents) cause Cursor to either:

  1. Fail to open with error: “Assertion Failed: Argument is undefined or null
  2. Open but display as blank (content exists when viewed in other editors)

CRITICAL FINDING: Even files created via shell commands (heredoc, cat) fail to open when created from within Cursor’s agent execution context, suggesting the issue is broader than just the write tool.

Environment

  • OS: macOS (darwin 25.2.0)
  • Editor: Cursor
  • File Type: Markdown (.md files)
  • Trigger: Files created/modified by AI agent tools OR shell commands executed by agents

Detailed Symptoms

Symptom 1: Null/Undefined Error

  • Error Message: “Unable to open ‘[filename].md’” followed by “Assertion Failed: Argument is undefined or null
  • Occurs: When attempting to open files created with:
    • The write tool
    • Shell commands executed by AI agents (cat, heredoc, etc.)
  • Example Files:
    • test_write_tool.md (created via AI agent write tool)
    • CURSOR_BUG_REPORT.md (created via shell heredoc from within agent context)
  • Status: File cannot be opened in Cursor at all

Symptom 2: Blank Display

  • Symptom: File opens in Cursor but appears completely blank
  • Reality: File contains valid content (verified via terminal, TextEdit, and other editors)
  • Example File: untitled.md (modified via AI agent search_replace tool)
  • Status: File opens but content is invisible in Cursor

Test Results

Files That Work Correctly :white_check_mark:

All created via shell commands executed OUTSIDE of Cursor’s agent context:

  • test_manual.md - Created with echo command (manual)
  • test_no_newline.md - Created with printf command (manual)
  • test_write_tool_fixed.md - Created with shell heredoc (manual)

Files That Fail :cross_mark:

Created/modified via AI agent tools OR shell commands executed WITHIN agent context:

  • test_write_tool.md - Created with write tool → Throws null error
  • CURSOR_BUG_REPORT.md - Created with shell heredoc (from agent) → Throws null error
  • untitled.md - Modified with search_replace tool → Displays blank

Technical Analysis

File Integrity Verification

All failing files pass standard file integrity checks:

  • :white_check_mark: Valid text encoding (ASCII or UTF-8)
  • :white_check_mark: Proper file permissions (-rw-r--r--)
  • :white_check_mark: Correct line endings
  • :white_check_mark: Content verified via cat, hexdump, file commands
  • :white_check_mark: Opens correctly in TextEdit and other editors

File Comparison

  • test_write_tool.md (fails) vs test_write_tool_fixed.md (works) are byte-for-byte identical
  • Same content, same encoding, same permissions
  • Only difference: creation method (AI tool vs manual shell command)

Key Finding: Execution Context Matters

The critical discovery: Files created via shell commands work when created manually, but FAIL when the same shell commands are executed by AI agents from within Cursor. This suggests:

  • The issue is NOT specific to the write tool
  • Cursor may have problems with files created by processes spawned from its agent execution context
  • Cursor’s file watcher may not properly handle files created by child processes
  • There may be a race condition or metadata issue when files are created while Cursor is actively monitoring the directory

Extended Attributes

  • All files have com.apple.provenance attribute (normal for macOS)
  • untitled.md additionally has com.apple.lastuseddate#PS and com.apple.macl (suggesting it was opened before)

Steps to Reproduce

Reproduction Steps

  1. Have an AI agent create a new markdown file using either:
    • The write tool, OR
    • Shell commands (cat, heredoc, echo, etc.)
  2. Attempt to open the file in Cursor
  3. Result: Either get null error or file opens blank

Note: The same shell commands work fine when executed manually outside of agent context.

Expected Behavior

Open a markdown file which was created or modified by an agent.

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.2.43
VSCode Version: 1.105.1
Commit: 32cfbe848b35d9eb320980195985450f244b3030
Date: 2025-12-19T06:06:44.644Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.2.0

Additional Information

Workarounds

  1. For new files: Create files manually first (outside Cursor or before agent execution), then have AI agents edit them
  2. For existing files: Use search_replace on files that already exist (though this can still cause blank display issue)
  3. Recovery: Files can be recovered by opening in TextEdit or other editors, then copying content to a new file
  4. For bug reports: Create markdown files manually outside of Cursor before opening

Impact

  • Severity: High - Data loss risk (files appear blank, user may think content is lost)
  • Frequency: Consistent - Happens every time AI agents create/modify markdown files
  • User Impact: Cannot reliably use AI agents to create or modify markdown files in Cursor
  • Scope: Affects both write tool AND shell commands executed by agents

Requested Fix

Please investigate:

  1. How Cursor handles files created by processes spawned from its agent execution context
  2. Why identical file content works when created manually but fails when created by agent-executed processes
  3. Why files modified via search_replace display as blank despite containing valid content
  4. Whether there’s a file metadata cache that needs to be invalidated
  5. Whether Cursor’s file watcher properly handles files created by child processes
  6. If there’s a race condition between file creation and Cursor’s file system monitoring

Additional Context

This issue occurs consistently across multiple projects, suggesting it’s a systematic problem with how Cursor processes files created/modified by AI agent tools or processes spawned by agents, not an isolated incident.

Meta Note: Multiple versions of this bug report were created using different methods (write tool, shell heredoc from agent) and ALL failed to open, perfectly demonstrating the bug being reported!


Report Generated: 2025-12-20 Test Files Available: All test files remain on Desktop for inspection Encoding Note: Some failing files are UTF-8, some are ASCII - encoding does not appear to be the root cause

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. This is a known issue related to the filesystem and markdown files created by the Agent.

Related thread: Create/Update .md files -- Unable to open: Assertion Failed: Argument is ‘undefined’ or ‘null’

Your analysis matches what we’ve seen: the problem is in how Cursor handles files created by processes running in the Agent execution context.

Workarounds:

  • Create the markdown files manually before running the Agent, then ask the Agent to edit them
  • After the Agent creates a file, open it in another editor, then copy the contents into a new file in Cursor

The team is already tracking this. Let me know if you can share any additional details.

1 Like