Repository Memory (AGENTS.md)
Engineering and codebase agents need durable project conventions that travel
with the repository across developers, CI jobs, and separate agent runs.
Rather than inventing a proprietary rule format, ISH implements the open
https://agents.md convention through AgentsMdMemory in
ish_context across all six SDKs.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
from ish import Agent, AgentsMdMemory
repo_mem = AgentsMdMemory("AGENTS.md")
agent = Agent(
name="developer",
model="gpt-4o-mini",
memory=repo_mem,
)
import { Agent, AgentsMdMemory, IshClient } from "ish-harness";
const client = new IshClient();
const repoMem = new AgentsMdMemory(client, "AGENTS.md");
const agent = new Agent({
name: "developer",
model: { provider: "openai_chat", name: "gpt-4o-mini" },
instructions: repoMem.load(),
});
repoMem.close();
client.close();
use std::sync::Arc;
use ish_harness::{Agent, AgentsMdMemory, OpenAIModel};
let repo_mem = AgentsMdMemory::new("AGENTS.md");
let agent = Agent::builder(Arc::new(model))
.name("developer")
.instructions(repo_mem.load())
.build()?;
package main
import (
"context"
"fmt"
"github.com/ish-harness/ish-harness/sdks/go"
)
func main() {
client, err := ish.NewClient()
if err != nil {
panic(err)
}
defer client.Close()
repoMem, err := ish.NewAgentsMdMemory(client, "AGENTS.md")
if err != nil {
panic(err)
}
defer repoMem.Close()
rules, err := repoMem.Load()
if err != nil {
panic(err)
}
result, err := client.Run(context.Background(), ish.AgentRunRequest{
AgentName: "developer",
Model: &ish.AgentModel{Provider: "openai_chat", Name: "gpt-4o-mini"},
SystemPrompt: ish.StringPtr(rules),
UserPrompt: ish.StringPtr("Review the diff for rule compliance."),
})
if err != nil {
panic(err)
}
fmt.Println(result["content"])
}
using Ish.Harness;
using var client = new IshClient();
using var repoMem = new AgentsMdMemory(client, "AGENTS.md");
var result = client.Run(new AgentRunRequest
{
AgentName = "developer",
Model = new AgentModel { Provider = "openai_chat", Name: "gpt-4o-mini" },
SystemPrompt = repoMem.Load(),
UserPrompt = "Review the diff for rule compliance.",
});
Console.WriteLine(result.GetProperty("content").GetString());
import io.github.ishharness.AgentsMdMemory;
import io.github.ishharness.IshClient;
import java.nio.file.Path;
try (var client = new IshClient(Path.of(System.getenv("ISH_NATIVE_LIBRARY")));
var repoMem = new AgentsMdMemory(client, "AGENTS.md");
var request = new IshClient.AgentRequest(
"gpt-4o-mini",
repoMem.load(),
"Review the diff for rule compliance.")
.agentName("developer")
.provider("openai_chat")) {
var result = client.runAgent(request);
System.out.println(result.path("content").asText());
}
Internally, AgentsMdMemory pairs a target file path ("AGENTS.md" by
default) with an in-memory MemoryStore for transient session notes and a
synchronized pitfalls cache for persistent, deduplicated lessons written
back to disk.
Session notes
| Operation | Where It Writes | Deduplication & Structure | Survives Restart |
|---|---|---|---|
append(text) | Internal MemoryStore (scope="agents_md", key="notes") | Newline-delimited append; surfaced under ## Notes by load() | No (session only) |
append_pitfall(pitfall, context) | In-memory pitfalls list + AGENTS.md on disk | Exact duplicate check against in-memory tuples and file lines; splices - <pitfall> (<context>) inside ## Pitfalls & Lessons Learned | Yes (Markdown on disk) |
When updating the file on disk, insert_markdown_section_item scans for an
existing ## Pitfalls & Lessons Learned heading and inserts the new bullet at
the end of that section immediately before the next #-prefixed heading—or
creates the section at the end of the file if none exists—preserving existing
sections and downstream document order.
When to Use AGENTS.md
- Codebase & Engineering Agents: Enforce repository architecture patterns, module boundaries, and build/test commands in version control.
- Team-Shared Invariants: Keep coding standards, disallowed APIs, and review checklists in a single file read by human contributors and agent SDKs alike.
- Continuous Pitfall Capture: Record post-mortem fixes and operational
gotchas programmatically via
append_pitfall/appendPitfall/AppendPitfallso future runs avoid repeating the same mistake.
AgentsMdMemory reads the configured file path (defaulting to "AGENTS.md" in
the current working directory). Pass an explicit path when loading from another
location, and avoid committing secrets or environment-specific credentials into
versioned Markdown.
Loading AGENTS.md into an Agent
Python's Agent(..., memory=repo_mem) calls repo_mem.get_system_prompt_block()
(which delegates to repo_mem.load()) and appends it to the agent's
instructions. In TypeScript, Rust, Go, C#, and Java, pass load() / Load()
directly into the agent's instructions or system prompt.
Record notes, pitfalls
append records session-only text under ## Notes, while append_pitfall /
appendPitfall / AppendPitfall writes deduplicated - <pitfall> (<context>)
entries under ## Pitfalls & Lessons Learned in the target AGENTS.md file
on disk.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
repo_mem.append("Keep validation rules in the shared runtime.")
repo_mem.append_pitfall(
"Do not use bare except blocks in API endpoint handlers.",
context="api",
)
print(repo_mem.load())
repoMem.append("Keep validation rules in the shared runtime.");
repoMem.appendPitfall(
"Do not use bare catch blocks in API endpoint handlers.",
"api",
);
console.log(repoMem.load());
repo_mem.append("Keep validation rules in the shared runtime.");
repo_mem.append_pitfall("Do not block the async executor.", "runtime");
println!("{}", repo_mem.load());
_ = repoMem.Append("Keep validation rules in the shared runtime.")
_ = repoMem.AppendPitfall("Always check returned errors before using values.", "runtime")
loaded, _ := repoMem.Load()
fmt.Println(loaded)
repoMem.Append("Keep validation rules in the shared runtime.");
repoMem.AppendPitfall("Do not block async continuations synchronously.", "runtime");
Console.WriteLine(repoMem.Load());
repoMem.append("Keep validation rules in the shared runtime.");
repoMem.appendPitfall("Close native handles in try-with-resources.", "runtime");
System.out.println(repoMem.load());