documentMemory stores text under a resource, project and environment.
Agents share documents through session bindings. Development and Production
are separate. Notes survive session end, compaction, sandbox replacement and
deployments; memory operations start no sandbox.
See Memory for the concepts, declaration and binding.
Configuration
The declaration registers a resource; a session binding chooses documents;
useMemory selects their projection and tools during render. Declarations
sharing an ID within a deployment must agree on provider and configuration.
- Promotion applies shared limits before activating code, including for sessions on older deployments. If activation fails, applied limits remain; retry the promotion.
- Lowering a limit never truncates notes or rejects deployment. Oversized documents remain readable; their next text replacement must fit.
- Changing provider kind requires a new resource and data migration.
Session bindings
Setmemory.<resource> when creating a session:
- For collections, use
"scope": "collection"and omitid. Access defaults toread; collection writes are unsupported. - Resources must be declared by the deployment and bound documents must exist. Invalid bindings fail admission.
- Bindings stay fixed. Schedules, channels and webhooks do not configure them.
- One store per project and environment. An application with many users keeps their data apart with document bindings and application-chosen document IDs; a collection binding sees every document of the resource, so it suits a single owner or a coordinating agent, not one user among many.
useMemory exposes the binding’s tools; omitting it exposes none.
An unbound hook fails before inference. Tools accept a memory resource ID,
required when multiple resources selected by that render offer the tool.
Descriptions list those eligible resources and their declared guidance.
Session inspection returns a memory array. Entries contain resource,
scope, optional document id, access and current writable. It is false
for read-only bindings, frozen/deleted documents and ended sessions.
Reusing a session-create Idempotency-Key requires identical agent, deployment,
environment and bindings; incompatible inputs return 409 idempotency_conflict.
The management API page has the full rules.
Start a session on a new document
A document and a session are separate objects: the document is owner data with its own lifetime, the binding is that session’s admission to it, and neither is created as a side effect of the other. Opening a topic in an application still means “these notes, this session”, so the SDK and the CLI do the two steps in order and make the pair converge on retry.- The document is created with
If-None-Match: *. An existing document is left as it is;documentis ignored then. A deleted id is reserved and fails before any session is created. - The session is created with an
Idempotency-Keyderived fromidempotencyKey. The same key with the same agent, deployment, environment and bindings returns the existing session; anything else under that key is a conflict error naming the cause.access(defaultread-write),memoryfor further bindings andsourceare passed through.
--memory <resource>=<documentId>[:read|read-write] binds a document
(read-write by default); --memory <resource> binds a collection.
--create-document creates each bound document that does not exist yet,
titled after its id, and reports it as created or existing. Add a prompt to
run the first turn at once, and --json for the ids.
Over HTTP, send PUT .../documents/<id> with If-None-Match: *, treat 412
as “exists” (then GET it; 404 means the id was deleted), and POST /api/managed-agents/sessions with an Idempotency-Key; 201 created the
session, 200 returned the one that key had already created. The helper’s
signature and errors are in the
TypeScript SDK reference.
Reading
The hook is synchronous; pass the definition or its ID:text: full document text or a collection overview.sources: included documents, each withid,title,revisionandupdatedAt. Empty documents returntext: ""and still have a source.writable: permission at recall, always false for collections. It neither reserves permission nor changes the binding’s tools. Later edits, freezes, deletion or session end can still prevent a save.
Collections
The overview contains recent entries in this format:memory_read; memory_list reaches documents beyond the overview. Model
calls, with a single selected resource:
id, title, text, summary, revision, updatedAt.
Lists return { documents, nextCursor }; entries omit text. Pass the opaque
cursor with the same resource/environment; null ends pagination. These tools
require a collection binding. Missing documents return status rejected,
reason not_found; invalid cursors return reason invalid_cursor.
Saving
memory_save replaces the bound document:
text is required. Omitting summary preserves it; "" clears it. Agents
cannot change IDs, titles or write policy. Results have these shapes:
saved commits independently of turn completion. conflict carries current
content for reconciliation. Rejections identify frozen or deleted documents,
a session whose end already revoked its writes, a field above its limit, a
resource the render did not select, or a read-only binding. bound lists
the resources the save could have targeted. These outcomes let the model continue; malformed arguments
and operational failures are tool errors.
Conflicts and retries
The host supplies the revision from the originating render. Every save and retry within that model response uses it: another writer’s edit causes a conflict, as does a second save after the first succeeds. Reconcile in the next model step; there is no automatic merge. A committed save whose reply was lost can conflict on retry. Read current content before writing again. Separately, model-generation retries can render again using newer memory; they do not preserve the same projection. Observed saves producememory.saved session events
with resource, documentId, revision, bytes. Delivery is best-effort: a
write can commit without a reply or event. Refresh documents when attaching,
reconnecting and completing work.
Owner access
The project’s Memory page shows documents, last writers and update times, including resources retired from active code. Owner edits use revision checks. Keep owner credentials in trusted application code. Install the CLI, then log in and link your project:--environment production for
production.
List metadata:
--text-file <path>, --text-stdin, and
--summary <text>. Create also accepts --frozen. Add --json for
structured output: list follows all pages and returns { documents }; show
returns the document object.
Disable agent writes
Freeze:agentWrites: "disabled"; after success, no later agent save can
commit. Earlier saves remain; reads and owner edits continue. Unfreeze enables
active bindings without reviving ended sessions or cancelling work.
Successful session end revokes its document-memory access. A failed or timed
out end has an uncertain outcome; freeze the document to block all agent
writes while resolving it. Remote providers have
a separate completion contract.
Export saved notes
--resource <id> to restrict it.
Each <out>/<resource>/<id>.json contains current document fields. Reads are
individual: this is not a consistent snapshot or revision/session backup.
Credentials, conversation history and sandbox files are excluded.
Delete a document
not_found. Copies in history, tool results
and exports remain. Use a new ID for new notes.
Management API
Usex-api-key: <api-key> on https://app.opencomputer.dev, as for the rest
of the management API. Every route requires
environment=development or environment=production as a query parameter.
Below, <p> is the project ID and <r> the resource ID.
Resource inventory
provider: stored kind and current limit.declared: whether any active deployment in the environment declares it.documents: count of non-deleted documents.
Documents
Paths are relative to this base; append?environment=development:
Create requires
If-None-Match: * and a never-used ID. Other mutations require
If-Match: "<revision>"; checks and writes happen together. JSON bodies:
- Create: required
title; optionaltext,summarydefault to"";agentWritesdefaults to"enabled". - Replace: required
text; omittedsummaryis preserved. - Patch:
title,agentWrites, or both. Omitted fields stay unchanged.
agentWrites accepts "enabled" or "disabled". Unknown fields are rejected.
Read, create, replace and patch return the document and its quoted ETag:
bytes counts UTF-8 text bytes; maxBytes is the current limit. The platform
sets writer to { kind: "owner" } or { kind: "agent", sessionId }.
Revision is opaque: retain ETag verbatim for If-Match. Delete returns no
new document ETag.
List returns { documents, nextCursor }, omitting text from entries. Pass
nextCursor as the cursor query parameter until null. Order is descending
update time, then ascending ID. Pagination is live; concurrent edits can move
documents between pages. Re-list for a complete current inventory.
Errors
Error bodies are{ error: { code, message } }:
Authentication/authorization failures return
401/403. On 412, read the
latest document and reconcile.
Network/server errors can leave mutations committed without acknowledgement.
Read current state before retrying; conditional writes protect newer content
but do not replay the original response.
Limits
Field limits are separate. These are not token budgets: memory shares the
model context with instructions, history and tools, without silent truncation.