Skip to content

Memory consolidation function contract

The consolidation worker (Enterprise) calls a function-mode AgentRuntime once per axis and workspace, then validates and applies the action list the function returns. This page lists the request body, every action, and the rejection reasons. To build a pack, see Write a consolidation pack. For the policy fields that bind a pack, see MemoryPolicy.

The worker sends POST http://<name>.<namespace>.svc.cluster.local:18080/functions/<name> with Content-Type: application/json. The name and namespace come from the MemoryPolicy.spec.consolidation.functionRefs.<axis> entry. Port 18080 is the function’s internal management-plane listener (facade-mgmt). The request carries Authorization: Bearer <token>, a projected ServiceAccount token for memory-api with the scheduleAuth.audience audience. The facade admits it when memory-api’s ServiceAccount is on the function’s OMNIA_SCHEDULE_AUTH_ALLOWED_SUBJECTS, which the operator sets for every workspace bound to a policy that names the function.

FieldTypeDescription
axisstringstaleObservations, crossScopeCandidates or entityDuplicateCandidates.
workspaceIDstringThe workspace UID.
bucketsarrayCandidate groups selected by the axis pre-filter.
gates.minDistinctUserCountmapResolved k-anonymity thresholds, keyed agentScoped and userScoped.
gates.requirePIIRedactionboolWhether the PII gate is on.

Each bucket has a key, an optional stats map, and entries. Each entry has:

FieldTypeDescription
idstringMemory row ID; on entityDuplicateCandidates, the memory entity ID. Use it in action targetIDs, fromIDs, mergeIDs and canonicalID.
contentstringThe row’s text.
scopeobjectworkspaceID, plus agentID and userID when set.
mutabilitystringOnly mutable rows can be modified.
sourceTypestringHow the row was written.
observedAttimestampWhen the row was observed. Always sent; 0001-01-01T00:00:00Z when unset, as on entityDuplicateCandidates.
metadatamap of stringRow metadata. Omitted when empty.

The response body must be a JSON array of actions with HTTP status 200. The action field selects the kind. An unknown action value or a malformed array fails the whole response, and the worker applies nothing from it.

actionFieldsRequired
create_summaryfromIDs, scope, content, metadatafromIDs non-empty, content non-empty. Sources may have any mutability.
supersedetargetIDs, withIDBoth.
rescopetargetIDs, newScope, reasontargetIDs non-empty.
invalidatetargetIDs, validUntil (RFC 3339), reasontargetIDs non-empty, validUntil in the future.
merge_entitiescanonicalID, mergeIDsBoth. Only mergeIDs rows must be mutable.
discardtargetIDs, reasontargetIDs non-empty. Soft-deletes the rows.
rescoretargetID, importance, confidencetargetID. Changes one row.

The validator checks each action independently. A rejected action is skipped and audited; the others still apply. The reason appears in the audit entry and in the outcome label of omnia_memory_consolidation_actions_total as rejected_<reason>.

ReasonCause
shape_invalidA required field in the table above is missing or empty.
target_unknownA modified row ID was not in the buckets sent for this call.
mutability_blockedA modified row is not mutable.
institutional_write_blockedA rescope targets the institutional scope (no agent or user).
anonymity_below_thresholdA rescope whose newScope has only an agentID or only a userID, and the largest stats.distinctUsers across the buckets sent is below gates.minDistinctUserCount for that scope. Defaults: agentScoped 5, userScoped 1.
scope_widening_unsupportedsafetyGates.maxScopeWidening is set to anything other than workspace.
scope_outside_workspaceA rescope newScope.workspaceID differs from workspaceID.
pii_blockedWhen requirePIIRedaction is on, the redactor finds PII in content (create_summary) or reason (rescope, invalidate, discard).

Accepted actions are applied one at a time, in order. Each action is atomic, but the actions do not share a transaction: when one fails to apply, the pass stops and earlier actions stay applied. Every applied action records the pack name and time on the rows it touches.