Skip to content

Commit a9eaec0

Browse files
authored
docs: refresh agent memory guardrails (raphaeltm#1114)
1 parent 7d60db9 commit a9eaec0

5 files changed

Lines changed: 84 additions & 3 deletions

File tree

.claude/rules/09-task-tracking.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ Verification must confirm all of:
8888

8989
If the session failed immediately, never started, launched under the wrong profile, or lost critical constraints, do not wait on it. Re-dispatch with the corrected task/profile or report the dispatch failure with exact status evidence.
9090

91+
If the requested specialist/profile is not available or cannot be observed from the dispatch result, do not assume it worked. Use the cheapest available status/details check, record what is missing, and either re-dispatch with an explicit supported profile or ask for clarification. A generic task running under the platform default is not a substitute for a requested reviewer, specialist, or constrained profile.
92+
93+
When a dispatched task returns, treat its output as usable only after checking that it came from the intended task/profile and respected the original constraints. If the result was produced by the wrong profile, ignored `draft PR`/`do not merge`, dropped the requested branch, or skipped `/do` when required, document the mismatch and do not use it as validation evidence.
94+
9195
### Why This Matters
9296

9397
Without the `/do` instruction, a dispatched agent may skip critical phases like staging verification, specialist review, or proper PR creation. The `/do` workflow enforces all quality gates defined in this project's rules.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Agent Feedback, Memory, and Idea Hygiene
2+
3+
## Why This Exists
4+
5+
SAM agents have repeatedly lost useful human feedback by leaving it only in transient conversations, or by letting stale ideas stay indistinguishable from current plans. Knowledge, ideas, and policies are product surfaces for agents. Treat them as maintained state.
6+
7+
## Before Key Decisions
8+
9+
Search project knowledge before making decisions that depend on remembered context:
10+
11+
| Decision | Search |
12+
| -------- | ------ |
13+
| Content, blog, launch copy | `ContentStyle` |
14+
| Libraries, tooling, code-quality tradeoffs | `CodeQuality` |
15+
| UI layout or interaction direction | `User`, `mobile`, and relevant surface names |
16+
| Architecture or runtime design | `Architecture` |
17+
| Pricing, billing, go-to-market | `BusinessStrategy` |
18+
19+
If a project policy applies, treat it as a hard gate unless it is explicitly categorized as a preference.
20+
21+
## When to Update Memory
22+
23+
Update durable memory when any of these happen:
24+
25+
- Raphaël explicitly states a preference, correction, or "do not do X" rule.
26+
- Work verifies that a stored observation is still accurate.
27+
- Work proves that a stored observation is stale, superseded, or too broad.
28+
- A repeated agent failure reveals a durable workflow rule that would prevent future frustration.
29+
30+
Do not save facts that are already obvious from the codebase, ephemeral task details, or speculation that has not been verified.
31+
32+
## Idea Maintenance
33+
34+
When reviewing or touching ideas:
35+
36+
1. Mark an idea completed only when the implementation is merged or otherwise verifiably shipped on the intended branch.
37+
2. If work exists only on an unmerged branch or draft PR, append a note with the branch/PR and leave the idea open.
38+
3. If an idea has become a narrower follow-up, update the title/content so future agents do not execute the stale original plan.
39+
4. If a prototype informed a real product change, record which production surface still needs validation; prototype routes are not the deliverable by default.
40+
5. Include concrete evidence in idea updates: merged commit, PR number, task ID, branch, or file path.
41+
42+
## Knowledge vs Ideas vs Policies
43+
44+
- **Knowledge** captures remembered facts and preferences agents should apply during work.
45+
- **Ideas** capture possible or planned product/engineering work.
46+
- **Policies** capture project-wide rules, constraints, delegation settings, and strong preferences.
47+
48+
Do not turn speculative ideas into policies. Do not use knowledge to replace a task or implementation checklist.
49+
50+
## Validation Checklist
51+
52+
Before finishing a memory/config maintenance task:
53+
54+
- [ ] New guidance points to existing detailed rules instead of duplicating large sections.
55+
- [ ] All added rule links and referenced files exist.
56+
- [ ] Ideas marked completed have merged/shipped evidence.
57+
- [ ] Unmerged, draft, or human-review work remains visibly open.
58+
- [ ] No duplicate knowledge observation was added when an existing active observation already covers it.

.codex/prompts/workflow.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ REPEAT until all subtasks are complete or failed:
134134
- **ALWAYS use `sleep` via the Bash tool**, not any other waiting mechanism. The Bash tool execution is what registers as session activity.
135135
- **ALWAYS re-read `.workflow-state.md` before each poll cycle.** Context compaction may have erased your memory of previous polls.
136136
- **ALWAYS call `update_task_status`** after each poll. This is your progress report AND your activity signal.
137-
- **If a subtask has been in_progress for more than 30 minutes** (6 poll cycles), send it a check-in message via `send_message_to_subtask` asking for a status update.
138-
- **If a subtask has been in_progress for more than 60 minutes** (12 poll cycles), flag it in your status update as potentially stuck.
139-
- **Maximum poll count: 200** (about 16 hours). If you hit this limit, report the timeout and stop.
137+
- **If a subtask has been in_progress for more than 30 minutes** (6 poll cycles), inspect available evidence and optionally send a check-in message via `send_message_to_subtask` asking for a status update.
138+
- **Do not treat duration alone as a stall.** Some `/do` subtasks legitimately run for multiple hours. Only report a subtask as stuck, retry it, or stop it when you have concrete failure evidence, impossible progress, an explicit blocker, or human instruction.
139+
- **Maximum poll count: 200** (about 16 hours). If you hit this limit, report the timeout with the evidence checked and stop.
140140

141141
### What to Do If Context Feels Fuzzy
142142

AGENTS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ Skills are invoked with `$skill-name` (Codex) or dispatched as subagents (Claude
5050
- `$do` — End-to-end task executor: research → plan → implement → review → staging → PR
5151
- `$workflow` — Multi-step workflow orchestration with foreground polling
5252

53+
## Operational Guardrails
54+
55+
These are Codex-facing reminders for recurring SAM workflow failures. The durable source of truth remains `CLAUDE.md` and `.claude/rules/*.md`.
56+
57+
| Situation | Do |
58+
| --------- | -- |
59+
| Starting SAM-managed work | Call the SAM MCP `get_instructions` tool first and apply returned knowledge and policy directives. |
60+
| Debugging a live issue Raphaël is seeing | Inspect production evidence first unless the issue is explicitly about staging or a branch verification. Use staging for PR validation and new-change verification. |
61+
| Debugging staging or deployment behavior | Query Cloudflare state/logs before guessing or redeploying. Staging deploys are slow; CF API checks are fast. |
62+
| User asks for "subtasks" | Use SAM `dispatch_task` for visible delegated work. |
63+
| User asks for "local subagents" | Use local Claude/Codex subagents for in-session critique or reasoning, not SAM-dispatched tasks. |
64+
| Dispatching a SAM task | Verify the task started, the title matches, the requested profile/agent is observable, and critical constraints such as `/do`, branch, `draft PR`, or `do not merge` survived. |
65+
| Draft PR / do-not-merge request | Preserve the constraint in task state and PR wording. Stop at the draft/open PR unless Raphaël later authorizes readiness or merge. |
66+
| Incidental bug found | If it is not blocking and not a small adjacent fix, file a backlog task with reproduction/evidence and continue the assigned work. |
67+
5368
## Prompts
5469

5570
Workflow prompts in `.codex/prompts/` (Codex) and `.claude/commands/` (Claude Code):

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ When you discover bugs or errors during testing — even if unrelated to your cu
201201
2. Include: Problem description, Context (where/when discovered), Acceptance Criteria checklist
202202
3. Continue with your current work
203203

204+
If the bug is blocking the current task or is a small adjacent fix, fix it in the current branch with evidence. Otherwise file it and keep the assigned work moving.
205+
204206
## Troubleshooting
205207

206208
- **Build errors**: Run builds in dependency order (see Build Order above)
@@ -214,6 +216,8 @@ Tasks tracked as markdown in `tasks/` (backlog -> active -> archive). See `tasks
214216

215217
**Dispatching tasks**: When dispatching tasks to other agents, always instruct them to use the `/do` skill, then verify the task actually started with the requested profile and title. Do not wait on failed, queued, missing, or wrong-profile sessions. See `.claude/rules/09-task-tracking.md`.
216218

219+
**Memory and ideas**: Keep SAM knowledge, ideas, and policies current when human feedback or shipped work changes what future agents should believe. Do not mark ideas complete unless they are merged or otherwise verifiably shipped. See `.claude/rules/38-agent-feedback-and-memory.md`.
220+
217221
## Strategy Planning
218222

219223
Strategic planning artifacts live in `strategy/` — see `strategy/README.md` for full structure.

0 commit comments

Comments
 (0)