Skip to content

Commit c855659

Browse files
flyingrobotsclaude
andcommitted
docs(agents): add 2-tier context system instructions
Document the Redis + knowledge graph handoff protocol: - Session start: bootstrap from handoff stream + search_nodes() - During work: continuous updates to Redis stream - Session end: mandatory handoff entry - Entity naming conventions for knowledge graph This ensures seamless context transfer between agent sessions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4c4bb72 commit c855659

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,106 @@ Welcome to the **Echo** project. This file captures expectations for any LLM age
1717
- Capture milestones, blockers, and decisions in relevant specs, ADRs, or PR descriptions.
1818
- AGENTS.md and `TASKS-DAG.md` are append-only; see `docs/append-only-invariants.md` plus `scripts/check-append-only.js` for the enforcement plan that CI will run before merges.
1919

20+
## Agent Context System (2-Tier)
21+
22+
Agents use a **2-tier context system** to maintain continuity across sessions:
23+
24+
| Tier | Store | Purpose | Update Frequency |
25+
| ---- | ----- | ------- | ---------------- |
26+
| **Immediate** | Redis stream | Current task state, branch, blockers | Every significant action |
27+
| **Deep** | Knowledge graph | Architecture decisions, patterns, entities | When learning something reusable |
28+
29+
### Session Start (Bootstrap)
30+
31+
1. **Read this file** (`AGENTS.md`) for project conventions
32+
33+
2. **Check Redis handoff stream**: `echo:agent:handoff` (most recent entry)
34+
35+
```text
36+
XRANGE echo:agent:handoff - + COUNT 5
37+
```
38+
39+
3. **Query knowledge graph** for relevant entities:
40+
41+
```python
42+
search_nodes("<feature_name>") # e.g., "BOAW", "MaterializationBus"
43+
search_nodes("Echo") # General project context
44+
```
45+
46+
### During Work (Continuous Updates)
47+
48+
**Redis stream** — Update after every significant action:
49+
50+
- Completing a task or subtask
51+
- Encountering a blocker
52+
- Making a key decision
53+
- Changing branches or PRs
54+
55+
```bash
56+
XADD echo:agent:handoff * \
57+
branch "graph-boaw" \
58+
status "IN_PROGRESS" \
59+
summary "Fixing determinism bug in view op emission" \
60+
current_task "Updating emit_view_op_delta_scoped()" \
61+
blockers "none" \
62+
timestamp "2026-01-19T22:00:00-08:00"
63+
```
64+
65+
**Knowledge graph** — Create/update entities when you:
66+
67+
- Discover an architectural pattern worth preserving
68+
- Complete a milestone (create `<Feature>_Phase<N>` entity)
69+
- Fix a non-obvious bug (create `<Feature>_BugFix` entity)
70+
- Make a decision that future agents should know about
71+
72+
```json
73+
{
74+
"name": "BOAW_Determinism_Fix",
75+
"entityType": "BugFix",
76+
"observations": [
77+
"Root cause: emit_view_op_delta() used delta.len() for view op IDs",
78+
"delta.len() is worker-local and varies by shard claim order",
79+
"Fix: derive op ID from intent scope (NodeId) which is content-addressed"
80+
]
81+
}
82+
```
83+
84+
### Session End (Handoff)
85+
86+
Before ending a session, **always** write a handoff entry:
87+
88+
```bash
89+
XADD echo:agent:handoff * \
90+
branch "<current-branch>" \
91+
status "<COMPLETE|IN_PROGRESS|BLOCKED>" \
92+
summary "<1-2 sentence summary of what was done>" \
93+
commits "<recent commit hashes and messages>" \
94+
next_steps "<what the next agent should do>" \
95+
blockers "<any blockers, or 'none'>" \
96+
tech_debt "<any shortcuts taken that need cleanup>" \
97+
test_commands "<commands to verify the work>" \
98+
timestamp "<ISO-8601 timestamp>"
99+
```
100+
101+
### Key Entities to Know
102+
103+
The knowledge graph contains ~300+ entities built by prior agents. Key patterns:
104+
105+
- `Echo Project` — Core project info and current focus
106+
- `<Feature>_Architecture` — Design decisions for major features
107+
- `<Feature>_Phase<N>` — Milestone completion records
108+
- `<Feature>_BugFix` — Non-obvious bug fixes worth remembering
109+
- `<Feature>_Tech_Debt_P<N>` — Tracked technical debt by priority
110+
111+
### Why This Matters
112+
113+
- **Quick tasks**: Redis handoff alone may suffice
114+
- **Complex tasks**: Query knowledge graph for architectural context
115+
- **Debugging**: Search for prior bug fixes in similar areas
116+
- **Decisions**: Check if prior agents already explored an approach
117+
118+
The 2-tier system means handoffs are seamless—no context is lost between agents, and institutional knowledge accumulates over time.
119+
20120
## Workflows & Automation
21121

22122
- The contributor playbook lives in `docs/workflows.md` (policy + blessed commands + automation).

0 commit comments

Comments
 (0)