Skip to main content

Memory Tools

Tools for reading and writing OpRelay's operational memory — facts, decisions, and context.


upsert_fact

Create or update a fact. Upserts on (project_key, category, key).

ParameterTypeRequiredDescription
project_keystringProject identifier
categorystringCategory for grouping (e.g. infra, ci, deploy)
keystringFact key within the category
value_jsonanyJSON value — any structured data (also accepted as value)
confidencenumber/stringEpistemic confidence: assumed (0.3), observed (0.6), inferred (0.7), confirmed (1.0), or a float 0–1
tagsstring[]Searchable tags (max 32)
sourcestringSource identifier (default: "manual")
agent_idUUIDAgent that created/updated the fact
run_idUUIDRun that produced this fact
await oprelay.call("upsert_fact", {
project_key: "myproject",
category: "infra",
key: "deploy.target",
value_json: { provider: "oci", region: "us-ashburn-1" },
confidence: "confirmed",
tags: ["deploy", "production"]
});

get_fact

Retrieve a single fact by category and key.

ParameterTypeRequiredDescription
project_keystringProject identifier
keystringFact key
categorystringCategory (narrows lookup)
const fact = await oprelay.call("get_fact", {
project_key: "myproject",
category: "infra",
key: "deploy.target"
});

forget_fact

Soft-delete a fact. Recoverable with restore_fact.

ParameterTypeRequiredDescription
project_keystringProject identifier
keystringFact key to forget
categorystringCategory (narrows lookup)

restore_fact

Restore a soft-deleted fact.

ParameterTypeRequiredDescription
project_keystringProject identifier
keystringFact key to restore
categorystringCategory (narrows lookup)

get_context

Bounded context retrieval. Returns facts, decisions, and recent runs scoped to intent and categories. This is how agents orient on session start.

ParameterTypeRequiredDescription
project_keystringProject identifier
intentstringstarting_task, reviewing, supervising, remediating, or general
task_idUUIDScope context to a specific task
ticket_idstringScope context to a ticket
include_categoriesstring[]Restrict facts to these categories (max 32)
exclude_categoriesstring[]Exclude facts from these categories
max_factsnumberFact limit (default: 5, max: 200)
max_decisionsnumberDecision limit (default: 3, max: 200)
max_runsnumberRun limit (default: 3, max: 200)
include_fact_metabooleanInclude fact metadata in response (default: false)
include_run_metabooleanInclude run metadata in response (default: false)
agentstringRequesting agent name (for context scoring)
const ctx = await oprelay.call("get_context", {
project_key: "myproject",
intent: "starting_task",
include_categories: ["infra", "ci", "deploy"],
max_facts: 10,
max_decisions: 5
});

clear_context

Delete all facts and decisions for a project. Irreversible.

ParameterTypeRequiredDescription
project_keystringProject identifier

list_categories

List all fact categories used in a project.

ParameterTypeRequiredDescription
project_keystringProject identifier

Returns an array of category strings.

const { categories } = await oprelay.call("list_categories", {
project_key: "myproject"
});
// ["ci", "deploy", "infra", "services"]

list_fact_keys

Browse fact keys, optionally filtered by category or key pattern.

ParameterTypeRequiredDescription
project_keystringProject identifier
categorystringFilter to a single category
patternstringSubstring or glob pattern to match key
const { keys } = await oprelay.call("list_fact_keys", {
project_key: "myproject",
category: "infra"
});
// ["deploy.target", "db.host", "db.port"]

list_projects

List all project keys visible to the caller.

No parameters required.

const { projects } = await oprelay.call("list_projects", {});
// [{ project_key: "myproject" }, { project_key: "ikeo-ops" }]