HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
protocol(memories): facts that change, standing records and observed conversations (#463)
github-actions[bot]42221743f4e5
diff --git a/protocol/CHANGELOG.md b/protocol/CHANGELOG.mdindex ad3ff4a5..5afcde9f 100644--- a/protocol/CHANGELOG.md+++ b/protocol/CHANGELOG.md@@ -136,6 +136,41 @@ its privileges on each. It is stated in what the caller may do, not in how accesserver that lets a member in by a role answers it as one that keeps a grant per memory does. §9names it as what an agent's tools are built from. Conformance: ME-01 asks it.+**Facts that change (§4.4), standing records and observed conversations, found while preparing+three public memory benchmarks for the second server.** A memory that keeps facts has to tell an update+("I moved to Porto") from an addition ("I got a fourth bike") and from a disagreement ("I have+never written a route", after describing one), keep the time something was said apart from the+time it became true, and give an agent its standing instructions without being asked. The chapter+had a word for none of these, so every writer and every server would have invented its own. Now:++- A fact's attributes have defined keys: `predicate`, `value`, `holds` (`one` or `many`),+ `stated_at`, `as_said`, `precision`, and `standing` (on any record). Without `time.valid_from`, a+ fact became true when it was said. A server that declares `holds` places a `one` fact among the+ others on its subject and predicate by their world time: what was true at T ends at T (a version+ of the server's own, `on_behalf_of` the writer), a different value from the same instant is+ linked with `contradicts` and both stay, and a fact about the past ends where the next value+ began. The answer to the write says what it did, in `closed` and `conflicts`, never stored.+- `contradicts` is a defined `rel`, kept on both records. A recall result on one side brings the+ other, after the ranked results, with `score` null and `why` `["contradicts"]`, outside `limit`.+- `GET /v1/memories/{id}/prime` reads a memory's standing records, newest first, within a token+ budget, from that memory alone unless `depth` widens it; a server priming an agent reads each+ memory it was granted at depth 0. The capability `prime` says whether a provider answers it.+- An observed episode carries `time.valid_from`, a content part may carry `name` beside `role`, and+ a conversation is observed one session to an episode, in order. A job says `queued`, `running`,+ `completed` or `failed` (`pending` stays for a provider that cannot tell the first two apart),+ with what it wrote, `closed`, `conflicts` and `usage`.+- A revision no longer changes the world time of the version it replaces: that version gets only+ its belief-time stamp, so `as_of` reads what the memory believed then. Stated because the second+ server's store did otherwise; its existing histories needed no repair.++Additive: every request and object valid before is valid now. Schema: `MemoryContentPart.name`, the+episode's `time`, `MemoryJob` (`memory_id`, `closed`, `conflicts`, `usage`, times; `queued` and+`running`), `MemoryRecord.closed` and `.conflicts` on a write's answer, `MemoryProvider.prime` and+`.holds`, `MemoryPrime` and its path. Suite `2026.10.4.post10`: ME-11 (five facts on one subject:+ended, linked, placed in the past, placed inside an earlier value), ME-12 (both sides of a+disagreement from a recall of one), ME-13 (the prime read: only standing records, newest first, a+budget, the memory alone).+- **Memories** ([Memories](versions/2026-10-04/memories.md)), the Harness Memories sub-protocol,optional at every class behind the `memories` capability. A memory is a named node in a tree:it holds records and may have child memories. A grant gives a principal privileges (`read`,diff --git a/protocol/conformance/uhp_conformance/__init__.py b/protocol/conformance/uhp_conformance/__init__.pyindex b1d7277c..2b46c89d 100644--- a/protocol/conformance/uhp_conformance/__init__.py+++ b/protocol/conformance/uhp_conformance/__init__.py@@ -3,7 +3,7 @@# and a report prints it as `suite_version`, so a report always names the code that produced it.# It used to be written twice, and from 2026.10.4 to 2026.10.4.post8 only the packaging copy moved:# every report of those nine revisions called itself 2026.9.12.post4.-__version__ = "2026.10.4.post9"+__version__ = "2026.10.4.post10"UHP_VERSION = "2026-10-04"# The MCP server the plugin checks point a plugin at. It must resolve and answer: a host is# allowed to refuse a server it cannot reach at configuration time and record that in `skipped`,diff --git a/protocol/conformance/uhp_conformance/checks.py b/protocol/conformance/uhp_conformance/checks.pyindex 8e61995e..6a49327a 100644--- a/protocol/conformance/uhp_conformance/checks.py+++ b/protocol/conformance/uhp_conformance/checks.py@@ -2307,6 +2307,143 @@ def me10(ctx):return f"{len(g.get('nodes') or [])} nodes, {len(g.get('edges') or [])} edges around {a['id']} on entities={prov['graph']['entities']}"+def _instant(s):+ """An ISO time as an instant, so `Z` and `+00:00` spellings of one moment compare equal."""+ from datetime import datetime+ return datetime.fromisoformat(str(s).replace("Z", "+00:00")) if s else None+++@check("ME-11", "A fact that holds one value ends what it replaced, keeps a disagreement, takes its place in the past, and says what it did",+ "full", f"{SPEC}/memories.md#44-facts-that-change")+def me11(ctx):+ prov = _memories_supported(ctx)+ if not prov.get("holds"):+ raise Skip("this provider does not declare holds: it keeps the attributes as written")+ base = f"/v1/memories/{_memory_child(ctx)['id']}/records"+ who = "Corvel " + uuid.uuid4().hex[:6]+ e = ctx.client.post(base, body={"type": "entity", "title": who})+ assert e.status == 200, f"POST an entity returned HTTP {e.status}: {e.text[:200]}"+ t0, t1, t15, t2 = "2023-01-01T00:00:00Z", "2024-01-01T00:00:00Z", "2024-03-01T00:00:00Z", "2024-06-01T00:00:00Z"++ def fact(city, t):+ r = ctx.client.post(base, body={+ "type": "fact", "title": f"{who} lives in {city}", "references": [{"rel": "subject", "record_id": e.json["id"]}],+ "attributes": {"predicate": "home_city", "value": city, "holds": "one", "stated_at": t}, "time": {"valid_from": t}})+ assert r.status == 200, f"POST a fact that holds one value returned HTTP {r.status}: {r.text[:200]}"+ f = r.json or {}+ assert isinstance(f.get("closed"), list) and isinstance(f.get("conflicts"), list), (+ f"the answer to remembering a fact that holds one value carries closed and conflicts, as lists; got {str(f)[:200]}")+ return f++ def read(rid):+ return ctx.client.get(f"{base}/{rid}").json or {}++ def ends(rid):+ return _instant((read(rid).get("time") or {}).get("valid_to"))++ a = fact("Lisbon", t1)+ assert a["closed"] == [] and a["conflicts"] == [], f"the first value ended or met nothing; got {a['closed']} {a['conflicts']}"+ b = fact("Porto", t2)+ assert b["closed"] == [a["id"]] and b["conflicts"] == [], (+ f"Porto from June must end Lisbon and meet nothing; got closed={b['closed']} conflicts={b['conflicts']}")+ lis = read(a["id"])+ assert _instant((lis.get("time") or {}).get("valid_to")) == _instant(t2), f"Lisbon must end where Porto began; got {lis.get('time')}"+ w = lis.get("written_by") or {}+ assert w.get("kind") == "provider" and w.get("on_behalf_of"), (+ f"the version that ended Lisbon is the server's own, on behalf of whoever wrote Porto; got written_by={w}")+ assert "closed" not in lis and "conflicts" not in lis, "closed and conflicts belong to the write's answer and are never stored"+ if (prov.get("history") or {}).get("content") == "versions":+ h = (ctx.client.get(f"{base}/{a['id']}/history").json or {}).get("data") or []+ first = next((v for v in h if v.get("version") == a.get("version")), None)+ assert first and (first.get("time") or {}).get("valid_to") is None, (+ "the version before the end keeps the world time it had: as the memory stood then, Lisbon had not ended")+ c = fact("Braga", t2)+ assert c["conflicts"] == [b["id"]] and c["closed"] == [], (+ f"Braga from the same day as Porto must be linked to it and end nothing; got closed={c['closed']} conflicts={c['conflicts']}")+ refs = lambda rid: {(x.get("rel"), x.get("record_id")) for x in read(rid).get("references") or []} # noqa: E731+ assert ("contradicts", b["id"]) in refs(c["id"]) and ("contradicts", c["id"]) in refs(b["id"]), (+ "contradicts says the same from either end: it must be kept on both records")+ assert ends(b["id"]) is None and ends(c["id"]) is None, "a disagreement closes neither side"+ d = fact("Faro", t0)+ assert d["closed"] == [] and d["conflicts"] == [], f"a fact about the past ends nothing that followed it; got {d['closed']} {d['conflicts']}"+ assert ends(d["id"]) == _instant(t1), (+ "Faro must end where Lisbon began, though Lisbon has itself ended: two values of one may not hold at once")+ co = fact("Coimbra", t15)+ assert co["closed"] == [a["id"]] and co["conflicts"] == [], (+ f"Coimbra from March falls inside Lisbon's time and must end it there; got closed={co['closed']} conflicts={co['conflicts']}")+ assert ends(a["id"]) == _instant(t15) and ends(co["id"]) == _instant(t2), (+ "Lisbon must now end in March, and Coimbra where Porto began")+ return f"five facts on {who}: ended, linked, placed in the past, and placed inside an earlier value"+++@check("ME-12", "A record found on one side of a disagreement brings the other", "full", f"{SPEC}/memories.md#63-the-response")+def me12(ctx):+ prov = _memories_supported(ctx)+ child = _memory_child(ctx)+ base = f"/v1/memories/{child['id']}/records"+ who = "Hollin" + uuid.uuid4().hex[:6]+ x = ctx.client.post(base, body={"type": "fact", "content": f"{who} signed the warehouse lease in May."})+ assert x.status == 200, f"POST records returned HTTP {x.status}: {x.text[:200]}"+ y = ctx.client.post(base, body={"type": "fact", "content": f"{who} has never signed a lease.",+ "references": [{"rel": "contradicts", "record_id": x.json["id"]}]})+ assert y.status == 200, f"POST a fact that contradicts another returned HTTP {y.status}: {y.text[:200]}"+ ids = {x.json["id"], y.json["id"]}+ back = {(ref.get("rel"), ref.get("record_id")) for ref in (ctx.client.get(f"{base}/{x.json['id']}").json or {}).get("references") or []}+ assert ("contradicts", y.json["id"]) in back, "contradicts written on one record must be kept on the other as well"+ signals = (prov.get("recall") or {}).get("signals") or []+ body = {"query": f"did {who} sign the lease?", "limit": 1} if "query" in signals else {"text": who, "limit": 1}+ deadline, res = time.time() + 40, {}+ while True:+ r = ctx.client.post(f"/v1/memories/{child['id']}/recall", body=body)+ assert r.status == 200, f"POST recall returned HTTP {r.status}: {r.text[:200]}"+ res = r.json or {}+ got = [x2 for x2 in res.get("results") or [] if (x2.get("record") or {}).get("id") in ids]+ if got or time.time() > deadline:+ break+ time.sleep(2)+ ctx.validate(res, "MemoryRecall")+ assert got, f"neither side of the disagreement was recalled with {body}"+ seen = {(g.get("record") or {}).get("id"): g for g in got}+ assert set(seen) == ids, (+ f"with limit 1 the best hit must bring the other side of the disagreement; got {sorted(seen)}")+ pulled = [g for g in got if g.get("why") == ["contradicts"]]+ assert len(pulled) == 1 and pulled[0].get("score") is None, (+ "the side brought along is marked why [\"contradicts\"] with no score, once")+ return f"limit 1 answered both sides of {who}'s lease"+++@check("ME-13", "A memory's standing records are read newest first, within a budget, from that memory alone", "full",+ f"{SPEC}/memories.md#91-what-a-session-does")+def me13(ctx):+ prov = _memories_supported(ctx)+ root, child = ctx.state["memory_root"], _memory_child(ctx)+ r = ctx.client.get(f"/v1/memories/{child['id']}/prime?budget=4000")+ assert r.status == 200, f"GET prime returned HTTP {r.status}: {r.text[:200]}"+ ctx.validate(r.json or {}, "MemoryPrime")+ if not prov.get("prime"):+ assert (r.json or {}).get("records") == [], "a provider that does not prime answers the prime read with an empty list"+ return "this provider does not prime, and answers an empty list"+ base = f"/v1/memories/{child['id']}/records"+ rule = ctx.client.post(base, body={"type": "procedure", "title": "Write dates as 1 March 2024", "attributes": {"standing": True}})+ time.sleep(1.1)+ pref = ctx.client.post(base, body={"type": "fact", "title": "Prefers answers of three sentences or fewer",+ "attributes": {"standing": True, "predicate": "prefers"}})+ plain = ctx.client.post(base, body={"type": "fact", "title": "The office closes at six"})+ assert rule.status == pref.status == plain.status == 200, "writing the standing records was refused"+ got = (ctx.client.get(f"/v1/memories/{child['id']}/prime?budget=4000").json or {})+ ids = [x.get("id") for x in got.get("records") or []]+ assert pref.json["id"] in ids and rule.json["id"] in ids and plain.json["id"] not in ids, (+ f"the prime read is the standing records and nothing else; got {ids}")+ assert ids.index(pref.json["id"]) < ids.index(rule.json["id"]), "standing records come newest first"+ assert got.get("truncated") is False and int(got.get("tokens") or 0) > 0, f"tokens and truncated as the read counted them; got {got}"+ tight = ctx.client.get(f"/v1/memories/{child['id']}/prime?budget=1").json or {}+ assert [x.get("id") for x in tight.get("records") or []] == [pref.json["id"]] and tight.get("truncated") is True, (+ "within a budget too small for any, the newest standing record still fits and the read says it left the rest out")+ above = [x.get("id") for x in (ctx.client.get(f"/v1/memories/{root['id']}/prime").json or {}).get("records") or []]+ assert pref.json["id"] not in above, "the prime read is of the memory alone unless depth widens it"+ return f"{len(ids)} standing records, newest first; a budget of one token kept the newest"++@check("ME-08", "A memory moves with its subtree, and deleting it takes the subtree", "full",f"{SPEC}/memories.md#2-the-memory-object")def me08(ctx):diff --git a/protocol/conformance/uhp_conformance/uhp-2026-10-04.schema.json b/protocol/conformance/uhp_conformance/uhp-2026-10-04.schema.jsonindex b869c35f..a7b06bdb 100644--- a/protocol/conformance/uhp_conformance/uhp-2026-10-04.schema.json+++ b/protocol/conformance/uhp_conformance/uhp-2026-10-04.schema.json@@ -2364,6 +2364,20 @@"trust": {"type": "string","const": "untrusted"+ },+ "closed": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Only on the answer to remembering a fact whose `holds` is `one`: the records it ended. Never stored."+ },+ "conflicts": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Only on the answer to remembering a fact whose `holds` is `one`: the records it was linked to with `contradicts`. Never stored."}},"additionalProperties": true@@ -2398,6 +2412,10 @@"tool"]},+ "name": {+ "type": "string",+ "description": "Who said it, when the role alone does not: two people in one conversation are both `user`."+ },"file": {"type": "object","required": [@@ -2554,6 +2572,19 @@}]},+ "time": {+ "type": "object",+ "properties": {+ "valid_from": {+ "type": [+ "string",+ "null"+ ],+ "description": "When it happened. Left out, now."+ }+ },+ "additionalProperties": true+ },"attributes": {"type": "object","additionalProperties": true@@ -2577,13 +2608,19 @@"id": {"type": "string"},+ "memory_id": {+ "type": "string"+ },"status": {"type": "string","enum": [+ "queued",+ "running","pending","completed","failed"- ]+ ],+ "description": "`pending` when the provider cannot tell queued from running."},"error": {"type": "string"@@ -2592,7 +2629,42 @@"type": "array","items": {"$ref": "#/$defs/MemoryRecord"- }+ },+ "description": "The records the job wrote."+ },+ "closed": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Records ended by a `one` fact the job wrote."+ },+ "conflicts": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Records linked with `contradicts` by a `one` fact the job wrote."+ },+ "usage": {+ "type": "object",+ "additionalProperties": true,+ "description": "Tokens, when a model did the work: `input_tokens`, `output_tokens`."+ },+ "created_at": {+ "type": "integer"+ },+ "started_at": {+ "type": [+ "integer",+ "null"+ ]+ },+ "finished_at": {+ "type": [+ "integer",+ "null"+ ]}}},@@ -2635,6 +2707,30 @@"description": "One of `{field, op, value}`, `{and: [...]}` or `{or: [...]}`.","additionalProperties": true},+ "MemoryPrime": {+ "type": "object",+ "required": [+ "records",+ "tokens",+ "truncated"+ ],+ "properties": {+ "records": {+ "type": "array",+ "items": {+ "$ref": "#/$defs/MemoryRecord"+ }+ },+ "tokens": {+ "type": "integer",+ "description": "The provider's own estimate of what the records cost."+ },+ "truncated": {+ "type": "boolean",+ "description": "True when a standing record was left out."+ }+ }+ },"MemoryRecallRequest": {"type": "object","properties": {@@ -3164,6 +3260,14 @@"none"]},+ "prime": {+ "type": "boolean",+ "description": "Whether the provider answers the prime read with its standing records."+ },+ "holds": {+ "type": "boolean",+ "description": "Whether the provider ends and links facts by `attributes.holds`."+ },"observe": {"type": "object","additionalProperties": truediff --git a/protocol/schema/uhp-2026-10-04.openapi.yaml b/protocol/schema/uhp-2026-10-04.openapi.yamlindex 7bdccea0..3a5b8be9 100644--- a/protocol/schema/uhp-2026-10-04.openapi.yaml+++ b/protocol/schema/uhp-2026-10-04.openapi.yaml@@ -782,6 +782,25 @@ paths:schema: { $ref: '#/components/schemas/MemoryJob' }'404': { $ref: '#/components/responses/NotFound' }+ /v1/memories/{memory_id}/prime:+ parameters:+ - $ref: '#/components/parameters/MemoryId'+ get:+ tags: [Memories]+ operationId: primeMemory+ summary: "The memory's standing records, newest first, within a token budget"+ description: "Needs `read`. The memory alone unless `depth` widens it."+ parameters:+ - { name: budget, in: query, schema: { type: integer, minimum: 1 } }+ - { name: depth, in: query, schema: { type: integer, minimum: 0 } }+ responses:+ '200':+ description: OK+ content:+ application/json:+ schema: { $ref: '#/components/schemas/MemoryPrime' }+ '404': { $ref: '#/components/responses/NotFound' }+/v1/memories/{memory_id}/records:parameters:- $ref: '#/components/parameters/MemoryId'@@ -2769,6 +2788,8 @@ components:name: { type: string, description: 'What a person calls the source.' }additionalProperties: truetrust: { type: string, const: untrusted }+ closed: { type: array, items: { type: string }, description: 'Only on the answer to remembering a fact whose `holds` is `one`: the records it ended. Never stored.' }+ conflicts: { type: array, items: { type: string }, description: 'Only on the answer to remembering a fact whose `holds` is `one`: the records it was linked to with `contradicts`. Never stored.' }additionalProperties: trueMemoryContentPart:type: object@@ -2779,6 +2800,7 @@ components:text: { type: string, description: 'The words of a text part, or the words that stand for a file.' }text_source: { type: string, enum: [stated, derived] }role: { type: string, enum: [user, assistant, system, tool] }+ name: { type: string, description: 'Who said it, when the role alone does not: two people in one conversation are both `user`.' }file:type: objectrequired: [id]@@ -2825,6 +2847,11 @@ components:required: [content]properties:content: { oneOf: [ { type: string, description: Shorthand for one text part. }, { type: array, items: { $ref: '#/components/schemas/MemoryContentPart' } } ] }+ time:+ type: object+ properties:+ valid_from: { type: [string, 'null'], description: 'When it happened. Left out, now.' }+ additionalProperties: trueattributes: { type: object, additionalProperties: true }MemoryJob:type: object@@ -2832,9 +2859,16 @@ components:properties:object: { type: string, const: memory.job }id: { type: string }- status: { type: string, enum: [pending, completed, failed] }+ memory_id: { type: string }+ status: { type: string, enum: [queued, running, pending, completed, failed], description: '`pending` when the provider cannot tell queued from running.' }error: { type: string }- data: { type: array, items: { $ref: '#/components/schemas/MemoryRecord' } }+ data: { type: array, items: { $ref: '#/components/schemas/MemoryRecord' }, description: The records the job wrote. }+ closed: { type: array, items: { type: string }, description: 'Records ended by a `one` fact the job wrote.' }+ conflicts: { type: array, items: { type: string }, description: 'Records linked with `contradicts` by a `one` fact the job wrote.' }+ usage: { type: object, additionalProperties: true, description: 'Tokens, when a model did the work: `input_tokens`, `output_tokens`.' }+ created_at: { type: integer }+ started_at: { type: [integer, 'null'] }+ finished_at: { type: [integer, 'null'] }MemoryWriter:type: objectdescription: 'Who wrote a record, stamped by the server from the authenticated caller. `kind` and `id` joined by a colon are the principal a grant would name.'@@ -2850,6 +2884,13 @@ components:type: objectdescription: 'One of `{field, op, value}`, `{and: [...]}` or `{or: [...]}`.'additionalProperties: true+ MemoryPrime:+ type: object+ required: [records, tokens, truncated]+ properties:+ records: { type: array, items: { $ref: '#/components/schemas/MemoryRecord' } }+ tokens: { type: integer, description: The provider's own estimate of what the records cost. }+ truncated: { type: boolean, description: True when a standing record was left out. }MemoryRecallRequest:type: objectproperties:@@ -3027,6 +3068,8 @@ components:id: { type: string }isolation: { type: string, enum: [container, enforced_filter] }derivation: { type: string, enum: [write_time, background, agent, none] }+ prime: { type: boolean, description: 'Whether the provider answers the prime read with its standing records.' }+ holds: { type: boolean, description: 'Whether the provider ends and links facts by `attributes.holds`.' }observe: { type: object, additionalProperties: true }recall: { type: object, additionalProperties: true }history: { type: object, additionalProperties: true }diff --git a/protocol/schema/uhp-2026-10-04.schema.json b/protocol/schema/uhp-2026-10-04.schema.jsonindex b869c35f..a7b06bdb 100644--- a/protocol/schema/uhp-2026-10-04.schema.json+++ b/protocol/schema/uhp-2026-10-04.schema.json@@ -2364,6 +2364,20 @@"trust": {"type": "string","const": "untrusted"+ },+ "closed": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Only on the answer to remembering a fact whose `holds` is `one`: the records it ended. Never stored."+ },+ "conflicts": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Only on the answer to remembering a fact whose `holds` is `one`: the records it was linked to with `contradicts`. Never stored."}},"additionalProperties": true@@ -2398,6 +2412,10 @@"tool"]},+ "name": {+ "type": "string",+ "description": "Who said it, when the role alone does not: two people in one conversation are both `user`."+ },"file": {"type": "object","required": [@@ -2554,6 +2572,19 @@}]},+ "time": {+ "type": "object",+ "properties": {+ "valid_from": {+ "type": [+ "string",+ "null"+ ],+ "description": "When it happened. Left out, now."+ }+ },+ "additionalProperties": true+ },"attributes": {"type": "object","additionalProperties": true@@ -2577,13 +2608,19 @@"id": {"type": "string"},+ "memory_id": {+ "type": "string"+ },"status": {"type": "string","enum": [+ "queued",+ "running","pending","completed","failed"- ]+ ],+ "description": "`pending` when the provider cannot tell queued from running."},"error": {"type": "string"@@ -2592,7 +2629,42 @@"type": "array","items": {"$ref": "#/$defs/MemoryRecord"- }+ },+ "description": "The records the job wrote."+ },+ "closed": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Records ended by a `one` fact the job wrote."+ },+ "conflicts": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Records linked with `contradicts` by a `one` fact the job wrote."+ },+ "usage": {+ "type": "object",+ "additionalProperties": true,+ "description": "Tokens, when a model did the work: `input_tokens`, `output_tokens`."+ },+ "created_at": {+ "type": "integer"+ },+ "started_at": {+ "type": [+ "integer",+ "null"+ ]+ },+ "finished_at": {+ "type": [+ "integer",+ "null"+ ]}}},@@ -2635,6 +2707,30 @@"description": "One of `{field, op, value}`, `{and: [...]}` or `{or: [...]}`.","additionalProperties": true},+ "MemoryPrime": {+ "type": "object",+ "required": [+ "records",+ "tokens",+ "truncated"+ ],+ "properties": {+ "records": {+ "type": "array",+ "items": {+ "$ref": "#/$defs/MemoryRecord"+ }+ },+ "tokens": {+ "type": "integer",+ "description": "The provider's own estimate of what the records cost."+ },+ "truncated": {+ "type": "boolean",+ "description": "True when a standing record was left out."+ }+ }+ },"MemoryRecallRequest": {"type": "object","properties": {@@ -3164,6 +3260,14 @@"none"]},+ "prime": {+ "type": "boolean",+ "description": "Whether the provider answers the prime read with its standing records."+ },+ "holds": {+ "type": "boolean",+ "description": "Whether the provider ends and links facts by `attributes.holds`."+ },"observe": {"type": "object","additionalProperties": truediff --git a/protocol/versions/2026-10-04/memories.md b/protocol/versions/2026-10-04/memories.mdindex 05f29319..2861c6cb 100644--- a/protocol/versions/2026-10-04/memories.md+++ b/protocol/versions/2026-10-04/memories.md@@ -251,7 +251,7 @@ memory, or with the same provider.**Records and references are the graph.** There is no second structure for entities andrelationships: a record is a node, and a reference is an edge from the record that holds it to the-record it names. `rel` says what the edge means. Five names have a defined meaning; any other is+record it names. `rel` says what the edge means. Six names have a defined meaning; any other iscarried unchanged.| `rel` | From | To | Meaning |@@ -261,6 +261,12 @@ carried unchanged.| `about` | any record | an `entity` | This record concerns that entity || `subject` | a `fact` | an `entity` | Who or what the fact says something of || `object` | a `fact` | an `entity` | Who or what it relates the subject to |+| `contradicts` | a `fact` | a `fact` | The two cannot both be true, and nothing says that one replaced the other ([§4.4](#44-facts-that-change)) |++`contradicts` says the same thing from either end, so a server that keeps it keeps it on both+records. Neither record is closed by it: a memory that holds a disagreement shows it rather than+deciding it. Like every reference it runs between records, not versions, and survives a revision of+either.A relationship between two entities that has something to say is therefore a **`fact`** with a`subject` and an `object`: "Dana is head of procurement at Quillon Freight" is a fact whose subject@@ -312,20 +318,67 @@ A record's `content` is an ordered list of **parts**. Two kinds of part are defi([§5](#5-operations)), by whoever may read the record.- **A string is shorthand** for one text part on a write. What is read back is always the list,so a client handles one shape.-- **A part may name who said it**: `role` is `user`, `assistant`, `system` or `tool`. A turn of a- conversation is observed ([§5.1](#51-two-ways-to-write)) as it happened, each part under its+- **A part may name who said it**: `role` is `user`, `assistant`, `system` or `tool`, and `name`+ says who when the role alone does not: two people in one conversation are both `user`. A turn of+ a conversation is observed ([§5.1](#51-two-ways-to-write)) as it happened, each part under itsrole, files included, with no shape of its own.- **A provider keeps what it says it keeps.** Its capability document lists the media types itkeeps in `content.media` ([§10.2](#102-the-capability-document)). A write that carries a file ofa media type the provider does not keep is refused with `memory_unsupported`; it is never storedwithout the file.+### 4.4 Facts that change++What was true changes: a person moves, buys a fourth bike, says the opposite of what they said+before. A fact's `attributes` may carry these keys, defined here so that every writer and every+server mean the same thing by them. Any other key is the writer's own.++| Key | Meaning |+|---|---|+| `predicate` | What kind of thing the fact says of its subject, as a short phrase: `home_city`, `pets`, `job`. A server MAY compare predicates in a normalized form (case, spacing, a plural), so a writer that reuses the word already held for a subject is understood |+| `value` | The value, briefly: `Chicago`, `a golden retriever named Max` |+| `holds` | `one` when the subject has one value of the predicate at a time (a home city, a job); `many` when values add up (pets, trips). Absent, nothing in this section applies |+| `stated_at` | When the source said it: the time of the turn or the document it came from. It is not `time.valid_from`, which is when it became true |+| `as_said` | The time as the source put it: "last week" |+| `precision` | How exact `time.valid_from` is: `instant`, `day`, `week`, `month` or `year` |+| `standing` | `true` on an instruction or a preference that applies, without being asked for, until it is changed ([§9.1](#91-what-a-session-does)). Any record may carry it |++A fact remembered without `time.valid_from` became true when it was said: a server takes+`stated_at` for it.++**One value at a time.** A server that declares `holds` ([§10.2](#102-the-capability-document))+places a fact whose `holds` is `one`, with subject S, predicate P and `valid_from` T, among the+active facts on S and P whose `holds` is `one`. Each was true from its `valid_from` until its+`valid_to`, or until now when that is null:++- One that was true **at** T, having become true before it, has ended at T, unless it has the same+ value and the new fact only says it again. The server writes a new version of it with `valid_to`+ set to T. That version is the server's own, `written_by` the provider `on_behalf_of` the writer+ of the new fact; the version before it keeps the world time it had+ ([§5.3](#53-nothing-is-overwritten)).+- One that became true **at** T with another value cannot be true with it, and nothing says which+ replaced which. Both stay, and the server links them with `contradicts`.+- When one became true **after** T, the new fact is history: it is kept with `valid_to` set to the+ earliest such `valid_from`.++So a fact that arrives late, about the past, takes its place in the past: it ends what it replaced+then, and what came after it still comes after it.++The answer to remembering a `one` fact carries `closed`, the ids of the records it ended, and+`conflicts`, the ids it was linked to with `contradicts`: both lists, empty when nothing happened,+and neither is stored on the record. A `many` fact ends nothing by being remembered; what stops+being true (a bike sold) is ended by a `revise` that sets its `valid_to`.++A record's current world time is its head's. Its history shows each version with the world time+the memory believed when that version was written.+## 5. Operations| Request | What it does ||---|---|| `POST /v1/memories/{id}/observe` | **observe**: append episodes; the provider decides what to derive from them || `GET /v1/memories/{id}/jobs/{job}` | What an `observe` that answered `202` has written since |+| `GET /v1/memories/{id}/prime` | What the memory gives an agent without being asked: its standing records ([§9.1](#91-what-a-session-does)) || `POST /v1/memories/{id}/records` | **remember**: write one record as stated || `POST /v1/memories/{id}/recall` | **recall**: search this memory and what is below it ([§6](#6-recall)) || `POST /v1/memories/{id}/graph` | **graph**: records as nodes and their references as edges, around one record or for the whole memory ([§6.6](#66-the-graph)) |@@ -344,10 +397,46 @@ A record's `content` is an ordered list of **parts**. Two kinds of part are defi- **`observe`** hands the provider raw episodes and nothing more. Whether a fact is extracted fromthem, when, and by what, is the provider's business. It is what a server calls after a turn([§9.1](#91-what-a-session-does)). When the provider derives after it answers, `observe` answers- `202` with `job: { id, status }` and no records yet; the job, read at its own route, carries- `status` (`pending`, `completed`, `failed`) and the records it produced. A provider is not- required to keep the episode itself as a record: one that keeps only what it derived says so+ `202` with `job: { id, status }` and no records yet. A provider is not required to keep the+ episode itself as a record: one that keeps only what it derived says so([§10.2](#102-the-capability-document)), and a client that needs the raw input later keeps it.++An episode is `{ content, time, attributes }`: its parts as they happened, each under its role and+name ([§4.3](#43-content)), and `time.valid_from`, when it happened (left out, now). A conversation+is observed one session to an episode, in the order the sessions happened; a provider MAY keep a+session as one record and each of its turns as a record `part_of` it. Observing again an episode+the memory already holds keeps nothing twice and derives nothing again, unless what was derived+from it failed.++```json+{ "episodes": [ {+ "content": [+ { "type": "text", "role": "user", "name": "Caroline", "text": "I adopted a dog last week." },+ { "type": "text", "role": "user", "name": "Melanie", "text": "What's its name?" }+ ],+ "time": { "valid_from": "2023-05-08T13:56:00Z" },+ "attributes": { "session": "s2" }+} ] }+```++A job, read at its own route, says how the derivation went:++```json+{ "object": "memory.job", "id": "hjob_41c0…", "memory_id": "hmem_7c1e…",+ "status": "completed", "error": "",+ "data": [ { "id": "hrec_…", "type": "fact", "title": "Caroline adopted a dog", … } ],+ "closed": [], "conflicts": [],+ "usage": { "input_tokens": 6200, "output_tokens": 900 },+ "created_at": 1790570000, "started_at": 1790570002, "finished_at": 1790570031 }+```++- `status` is `queued`, `running`, `completed` or `failed`, as a consolidation run's is+ ([§9.2](#92-consolidation-runs)). A provider that cannot tell queued from running says+ `pending`.+- `data` is the records the job wrote; `closed` and `conflicts` are what writing them did+ ([§4.4](#44-facts-that-change)); `usage` is present when a model did the work.+- A failed job says why in `error` and leaves the episodes kept. Observing them again starts a new+ job.- **`remember`** writes the record the caller states, as stated. It is what an agent calls when itdecides something is worth keeping.@@ -476,6 +565,10 @@ Any one may be given alone. Given together, the provider fuses them into one ran- `memory` names the memory each result is in: the one asked, or one below it. It is where thecaller goes next.- `why` names the signals that produced each result.+- A result whose record has a `contradicts` reference brings the record at its other end, when the+ caller may read it and it is active: after the ranked results, once however many results name+ it, with `score` null and `why` `["contradicts"]`, and not counted against `limit`. A reader who+ finds one side of a disagreement is shown the other.- `degraded` lists what the request asked for and was not done (`"text:not_supported"`,`"subtree:capped_at_200_memories"`). A server MUST NOT ignore part of a request silently.- `parent` is absent on a root, and equally absent when the caller may not read the parent: the two@@ -691,14 +784,37 @@ A harness adds two settings of its own:| Moment | Called by | What happens ||---|---|---|-| **Prime** | server, at session start and after the conversation is compacted | The server reads what the provider marks as always-relevant in each memory the agent was granted and places it, with each memory's `name`, `description` and children, in the agent's instructions |+| **Prime** | server, at session start and after the conversation is compacted | The server reads the standing records of each memory the agent was granted and places them, with each memory's `name`, `description` and children, in the agent's instructions || **Tools** | agent, during a turn | `memory_list`, `memory_recall`, `memory_graph`, `memory_get`, `memory_remember`, `memory_revise`, `memory_forget`, `memory_run_query` for the named queries a memory lists, `memory_operate` for a type's operations, and `memory_query` where a provider offers free queries. Write tools are offered only to an agent that holds `write` somewhere. The memories it was granted are where the agent starts; from each it may walk to the parent and the children a response names, and on from there, as far as its own privileges reach. The server checks every step || **Observe** | server, when a turn ends | The turn (what was asked, what was answered, which tools ran) is sent to the default memory as episodes. No model is involved on the server's side || **Consolidate** | server, on a schedule or when idle | The server asks the provider to do its background work. What that is belongs to the provider |-How much a provider returns for priming is the provider's decision. The server records what it-placed, per memory, in tokens, with the turn, so-the cost is visible even where it is not set by the client.+A memory's standing records are its instructions and preferences: the active records whose+`attributes.standing` is `true` ([§4.4](#44-facts-that-change)). They are read at their own route,+so a server that runs the agent and does not keep its memories asks the server that does:++```http+GET /v1/memories/{id}/prime?budget=4000+```++```json+{ "records": [ { "id": "hrec_…", "type": "procedure",+ "title": "Format every code snippet with syntax highlighting",+ "attributes": { "standing": true }, … } ],+ "tokens": 412, "truncated": false }+```++- The records are newest first, taken in that order until the next would pass `budget` tokens;+ the first always fits. `tokens` is what the provider counted, an estimate it states and does not+ have to meet exactly; `truncated` is true when a standing record was left out.+- It reads the memory alone. `depth` widens it as it widens `recall`+ ([§6.2](#62-the-request)), and a server priming an agent reads each memory of the agent's+ granted listing ([§9](#9-an-agent-and-its-memories)) at depth 0, the budget divided between them:+ a company's root would otherwise put every team's preferences into every turn.+- It needs `read`, and returns only what the caller may read.++The server records what it placed, per memory, in tokens, with the turn, so the cost is visible+even where it is not set by the client.Priming is not repeated every turn. Instructions that change every turn defeat prompt caching, andretrieval during a turn is what the tools are for.@@ -776,7 +892,7 @@ GET /v1/memories/providers"history": { "content": "versions", "structure": "versions" },"revise": "native", "forget": "native","erase": { "unreachable": "reported" },- "prime": true, "consolidate": "runs",+ "prime": true, "consolidate": "runs", "holds": true,"queries": { "named": true,"free": { "languages": ["cypher"], "write": false } },"types": true,@@ -796,6 +912,11 @@ GET /v1/memories/providersthem in what it is given and relates them itself), `stated` (it keeps the ones a writer statesand finds none of its own) or `none` (it keeps no record of that type). The graph read([§6.6](#66-the-graph)) works on all three.+- **`prime`** is true when the provider answers the prime read ([§9.1](#91-what-a-session-does));+ one that does not answers it with an empty list.+- **`holds`** is true when the provider ends and links facts by `holds`+ ([§4.4](#44-facts-that-change)). One that does not keeps the attributes as written, answers+ neither `closed` nor `conflicts`, and leaves `contradicts` to whoever writes it.### 10.3 What an adapter owes