Skip to main content

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.

from ish import Agent, AgentsMdMemory

repo_mem = AgentsMdMemory("AGENTS.md")

agent = Agent(
name="developer",
model="gpt-4o-mini",
memory=repo_mem,
)

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​

OperationWhere It WritesDeduplication & StructureSurvives 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 diskExact duplicate check against in-memory tuples and file lines; splices - <pitfall> (<context>) inside ## Pitfalls & Lessons LearnedYes (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 / AppendPitfall so 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.

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())