Skip to content

Folder named agents.md in a parent directory blocks all instructions (EISDIR): "Instruction initialization blocked by unavailable sources: core/instructions" #52301

Closed

Description

@hilleer

Description

When a parent directory of the project contains a folder named agents.md (in my case a git clone of a repository called agents.md), every prompt in that project fails with:

Session failed: Instruction initialization blocked by unavailable sources: core/instructions

V2 searches for AGENTS.md from the project up to $HOME (#41633). On macOS's case-insensitive file system, the lookup for ~/code/org/AGENTS.md matches the folder ~/code/org/agents.md/. Reading it fails with EISDIR, and that single failure blocks every instruction source, so the session cannot run.

Expected: Paths that aren't regular files are skipped, and the session runs normally.

Actual: Every prompt fails. Log:

level=WARN message="failed to load instruction source" source=project
  cause=FileSystem.readFile (/Users/…/code/xxx/agents.md) EISDIR: illegal operation on a directory
level=ERROR message="Failed to drain Session"
  cause="Instructions.InitializationBlocked: Instruction initialization blocked by unavailable sources: core/instructions"

Additional findings:

  • After moving the folder away, sessions keep failing until opencode service restart. The failed source is cached in the running service and not retried (no new "failed to load instruction source" line is logged).
  • Worked in V1, which didn't search above the project root.

Suggested fix:

  1. During AGENTS.md discovery, skip paths that aren't regular files (similar to the EISDIR handling in readFileStringSafe does not catch EISDIR - TUI crashes on every launch with Unexpected server error (exit 133 / SIGTRAP) #32205).
  2. Don't let one failing instruction source block all instructions.
  3. Retry failed sources instead of caching the failure until the service restarts.

Plugins

No response

OpenCode version

opencode v2.0.20

Steps to reproduce

  1. On macOS (case-insensitive file system), create a folder ~/code/org/agents.md/. In my case it's a git clone of a repository named agents.md; an empty folder should do.
  2. Start OpenCode in a sibling project, e.g. ~/code/org/some-repo.
  3. Send any prompt, and it fails with "Instruction initialization blocked by unavailable sources: core/instructions".
  4. Remove or move ~/code/org/agents.md/ and send another prompt. It still fails.
  5. Run opencode service restart and send another prompt. It now works.

Screenshot and/or share link

Image

Operating System

MacOS

Terminal

Ghostty

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    • #52290: Reports the same Instruction initialization blocked by unavailable sources: core/instructions failure on the first prompt, though its root cause is not yet clear.
  2. hilleer commented on Sep 30, 2026

    @hilleer
    Author

    This issue might be a duplicate of an existing issue. Please check:

    • #52290: Reports the same Instruction initialization blocked by unavailable sources: core/instructions failure on the first prompt, though its root cause is not yet clear.

    similar error message reported but the cause seem to be very different

  3. foma-agent commented on Oct 2, 2026

    @foma-agent

    #52576 merged into v2.0.22. This issue is still open.

    I didn't start OpenCode. On a Linux tree with a directory named AGENTS.md above two real files, v2.0.21 fs.up (exists) included the directory. readFileStringSafe still only catches NotFound and PermissionDenied, so EISDIR is isolated into Instructions.unavailable and the whole project source dies. v2.0.22 type: "file" skipped the directory and the files stayed available.

    Nested after a read: with the directory between two files on the walk, a load that throws on EISDIR is swallowed and every later AGENTS.md is dropped. type: "file" keeps those later files.

    instruction-discovery.test.ts now expects type: "file" on the options object. It does not create an AGENTS.md directory.

  4. Tarquinen commented on Oct 20, 2026

    @Tarquinen
    Member

    This was fixed by #52576. That PR merged into the v2 branch, so GitHub didn't close this issue automatically. Closing as completed.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions