Skip to main content
The AGENTS.md API manages persistent instruction files attached to the thread tree. A file can exist at the workspace root or inside a thread folder. Threads use the nearest active file from their folder ancestry. The methods live under thread/agents_doc/* because AGENTS.md is part of the workspace thread tree, not the artifact store. Payloads use snake_case field names.

Methods

thread/tree also returns an agents_docs array containing ThreadAgentsDocSummary items. Summaries never include full file content.

Status and save reason

draft means the explicit document exists but is empty. Drafts are visible to clients but are not effective prompt sources. active means non-empty content and participates in inheritance. archived means deleted from the user-facing tree.

Payloads

ThreadAgentsDocPayload includes full content:
For a root file, folder_id is omitted or null. ThreadAgentsDocSummary is the content-free tree shape:
ThreadAgentsDocResolvedPayload describes the effective active file for a requested scope or thread:
source_folder_id is omitted for a root source. source_path is an array of folder names from the thread tree root to the source folder.

Reading a scope

Call thread/agents_doc/get when opening an AGENTS.md editor for root or folder scope.
Response:
explicit can be absent when the requested scope has no local file. effective can be absent when no active file exists in the scope ancestry. For the root scope, omit folder_id:

Saving

Clients save the explicit file for one scope. The gateway normalizes line endings and computes content_sha256.
Response:
If content is empty or whitespace-only after normalization, the saved document status is draft. Drafts are not injected into prompts. expected_version is optional but recommended for any editor with autosave. If the current server version differs, the gateway returns a JSON-RPC error with code -32600 and a message containing the expected and actual versions. content is limited to 65536 characters.

Archiving

Archive removes the explicit file from the visible tree and allows inherited parent files to become effective again.
Response:
If there was no explicit file for the scope, archived is false.

Resolving for a thread

Use this method when a client needs to inspect the effective file for a specific thread.
Response:
If the thread has no placement, the gateway resolves against the root scope.

Thread tree summaries

thread/tree includes AGENTS.md summaries:
Clients should use these summaries to render sidebar file rows and call thread/agents_doc/get only when opening the editor.

Notifications

The gateway sends thread/agents_doc/changed after save or archive:
The gateway also sends thread/tree/changed so tree-based clients can refresh summaries. Treat notifications as invalidation hints; reload the affected scope or tree before rendering stale state as authoritative.

Errors

Common validation errors use standard JSON-RPC codes:

Schemas

Generated schemas include:
  • /schemas/thread_agents_doc_status.json
  • /schemas/thread_agents_doc_save_reason.json
  • /schemas/thread_agents_doc_payload.json
  • /schemas/thread_agents_doc_summary.json
  • /schemas/thread_agents_doc_resolved_payload.json
  • /schemas/thread_agents_doc_get_params.json
  • /schemas/thread_agents_doc_get_response.json
  • /schemas/thread_agents_doc_save_params.json
  • /schemas/thread_agents_doc_save_response.json
  • /schemas/thread_agents_doc_archive_params.json
  • /schemas/thread_agents_doc_archive_response.json
  • /schemas/thread_agents_doc_resolve_for_thread_params.json
  • /schemas/thread_agents_doc_resolve_for_thread_response.json
  • /schemas/thread_agents_doc_changed_notification.json