Skip to content

Load global AGENTS.md into native agent system prompt#56757

Merged
rtfeldman merged 4 commits into
mainfrom
AI-231/global-agents-md
May 14, 2026
Merged

Load global AGENTS.md into native agent system prompt#56757
rtfeldman merged 4 commits into
mainfrom
AI-231/global-agents-md

Conversation

@rtfeldman
Copy link
Copy Markdown
Contributor

@rtfeldman rtfeldman commented May 14, 2026

Watches a user-global AGENTS.md file alongside settings.json (at ~/.config/zed/AGENTS.md on macOS/Linux, %APPDATA%\Zed\AGENTS.md on Windows) and includes its trimmed contents in the native agent's system prompt.

This matches the pattern used by Codex (CODEX_HOME/AGENTS.md, defaulting to ~/.codex/AGENTS.md) and OpenCode (~/.config/opencode/AGENTS.md): personal instructions live next to other app config and apply across every project the user opens.

Behavior

  • Native Zed agent only. Not passed to ACP / external agents.
  • Reads the local config dir, so SSH-remoted projects still get the local user's personal AGENTS.md (project rules continue to come from the remote workspace).
  • Missing, empty, or whitespace-only files are silently treated as no AGENTS.md.
  • Read errors surface through the same notification UI as settings errors, with a stable notification ID that's dismissed once the file becomes readable again.
  • The file is read in full, matching how existing project rules / repo AGENTS.md files are loaded today.

System prompt rendering

In the system prompt, the user-global AGENTS.md appears as ### Personal AGENTS.md immediately before ### Project Rules, so the model sees personal defaults first and project guidance later (project rules take precedence on conflicts).

Tests

  • user_agents_md watcher: initial load, empty/whitespace ignored, reacts to file edits.
  • SystemPromptTemplate: renders personal AGENTS.md before project rules; omits the section when no user AGENTS.md is present.

Closes AI-231

Release Notes:

  • Added support for a global AGENTS.md file alongside settings.json, which is included in all projects' system prompts in the Zed Agent

Watches a user-global AGENTS.md alongside settings.json and includes its trimmed contents in the native agent's system prompt, rendered before project-level rules so per-project guidance can override personal defaults.

Missing, empty, or whitespace-only files are treated as no AGENTS.md. Read errors surface through the same notification UI as settings errors.
@rtfeldman rtfeldman self-assigned this May 14, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 14, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 14, 2026
rtfeldman added 3 commits May 14, 2026 10:43
Collapses the previous struct (Option<content>, Option<error>) into a three-variant enum so that loaded/empty/error states are mutually exclusive, and removes the redundant UserAgentsMdStatus type since the enum now serves both as in-memory state and as the value passed to the on-change callback.
Matches the SettingsStore pattern: one wrapper struct (UserAgentsMd) holds the data plus a _watcher: Task<()> field, and the enum (now UserAgentsMdState) describes only the data variants. The watcher's lifetime is tied to the data it produces, so replacing the global cancels the watcher.
@rtfeldman rtfeldman marked this pull request as ready for review May 14, 2026 14:54
@rtfeldman rtfeldman enabled auto-merge May 14, 2026 14:54
@cole-miller cole-miller self-requested a review May 14, 2026 14:56
@rtfeldman rtfeldman added this pull request to the merge queue May 14, 2026
Merged via the queue into main with commit 29ca37f May 14, 2026
32 checks passed
@rtfeldman rtfeldman deleted the AI-231/global-agents-md branch May 14, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants