--- id: MEM-1 family: GR-MEM level: extended profiles: [storage-api, runtime] posture: normative-target added: "1.0" changed: "1.0" source: https://flowdrop.io/spec/rules/gr-mem/mem-1 specification: FlowDrop Workflow Specification 1.0 licence: CC BY 4.0 --- # MEM-1 — Appending a tool result twice appends it once *GR-MEM (Part I) · level: extended · profiles: storage-api, runtime · added in 1.0* An agent loop that retries a step, or an orchestrator that re-delivers a result, would double the conversation without a guard. The buffer decides by the tool call's id, so a repeat is a no-op rather than a second turn. ## The rule > **Normative.** This is the rule. > > 1. Appending to a conversation buffer MUST be idempotent by tool call id. > > 2. A `tool`-role message whose tool call id already appears anywhere in the buffer (already stored, or added earlier in the same append) MUST be dropped and MUST NOT be appended. > > 3. The reported message count MUST reflect the deduplicated buffer. > > 4. The one exception is an id currently held by a synthetic healed placeholder: a `tool`-role message with that id MUST replace the placeholder and MUST NOT be deduplicated. ## What it means A retried step or a re-delivered result carries the same tool call id it carried the first time, so the buffer can tell a repeat from a second call without any cooperation from whatever is retrying. The count reported back is the deduplicated count, not a running total, so a re-fire is invisible to anything reading it afterward. The exception is the clause worth reading twice: an id currently held by a synthetic healed placeholder is not deduplicated against — it is replaced. Without that exception, a real result landing after MEM-3 healed its call would be dropped as a duplicate of its own placeholder, and the buffer would keep telling the model the call was interrupted after it had in fact returned. ## Example A buffer already holds a turn that declared tool call `c1` and a result that answered it. ```json title="A result naming an id already answered" verdict="dropped" { "role": "tool", "content": "re-fired result", "tool_call_id": "c1" } ``` ```json title="A result naming an id not yet seen" verdict="appended" { "role": "tool", "content": "second result", "tool_call_id": "c2" } ``` Now the same id is held only by a synthetic placeholder, not a real result: ```json title="A placeholder still standing in for c1" verdict="held" { "role": "tool", "content": "Tool call was interrupted; no result.", "metadata": { "tool_call_id": "c1", "healed": true } } ``` ```json title="The real result for c1 arriving late" verdict="replaced" { "role": "tool", "content": "Found 3 cats", "tool_call_id": "c1" } ``` ## Why Recorded under [OPEN-25](https://flowdrop.io/spec/rulings/open-25). ## Related rules - Names: MEM-2, MEM-10, MEM-11 - Referenced by: MEM-2, MEM-10, MEM-11, MEM-14 --- Rule identifiers are permanent and are never renumbered. This specification carries no implementation status: each implementation publishes its own standing against these rules. Licensed CC BY 4.0.