Skip to content

Subagents resolve relative markdown links in .agent.md against cwd instead of the agent file's directory (linked docs fail to load) #4122

Description

@xirzec

Summary

Custom agent definitions (.github/agents/*.agent.md) commonly reference supporting docs with paths relative to the agent file, e.g.:

Follow the full guidelines in [architecture-review-guidelines.md](../prompts/architecture-review-guidelines.md).

When a subagent runs, (1) the harness does not auto-inline the linked markdown, and (2) if the agent follows the link literally it resolves the relative path against its working directory (repo root), not against the agent file's directory (.github/agents/). The link points to a non-existent path and the guidelines silently fail to load.

Repro

Repo: Azure/azure-sdk-for-js, agent file .github/agents/archie.agent.md links ../prompts/architecture-review-guidelines.md.

  • Agent cwd: <repo> (e.g. D:\src\azure-sdk-for-js)
  • Link resolved against cwd -> <repo>\..\prompts\... -> D:\src\prompts\architecture-review-guidelines.md -> does not exist
  • Actual file -> <repo>\.github\prompts\architecture-review-guidelines.md -> exists
  • Resolved against the agent file dir -> .github\agents\..\prompts\... -> .github\prompts\... -> correct

Evidence

Probing the archie subagent (tools forbidden) confirmed only the .agent.md body is in context -- the linked file's text is not inlined. A second probe confirmed the literal ../prompts/... path resolves to D:\src\prompts\... (missing) from cwd. All 9 agent files in that repo share this pattern.

Expected

Relative links in an .agent.md should resolve relative to the agent file's own directory (matching GitHub web / editor rendering), and/or the harness should auto-inline referenced markdown into the subagent's context.

Impact

Subagents run without their full guidelines, degrading review quality, with no error surfaced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions