Reason with Tenzro Cortex
Buy budgeted reasoning from Cortex workers, cap loops, cost and deadline, read the signed receipt and give an agent memory to reason over.
Cortex is the network's reasoning tier. A Cortex worker runs a recurrent-depth model that loops over its own hidden state before it answers, and each loop is a priced, budgeted resource. You say how deep to think, how much to spend and how long to wait; the worker answers inside those limits or refuses, and every answer comes with a signed receipt. This tutorial makes a request, bounds it, checks the receipt and adds agent memory.
Prerequisites
- Node.js 20+ and
npm install tenzro-sdk, or thetenzroCLI. - An account with TNZO to pay for requests (fund it by transferring TNZO to its address), or an agent with a delegation scope that allows
inference. - For the memory steps: an agent DID. See Create an agentic wallet.
1. Find the workers
List the Cortex workers this node knows, and those it has learned about from the network:
import { TenzroClient } from "tenzro-sdk";
const client = new TenzroClient({ endpoint: "https://rpc.tenzro.xyz" });
const local = await client.cortex.listWorkers();
const remote = await client.cortex.listRemoteWorkers();
console.log(local.count, remote.count);
console.log(remote.workers);tenzro cortex list --rpc https://rpc.tenzro.xyzEach entry names the model, the worker's DID and its pricing. Pick a model_id from the list for the next steps.
2. Make a one-shot request
The simplest call names a model, the input and a tier:
const MODEL = "<cortex-model-id>";
const reply = await client.cortex.reason(
MODEL,
"Three providers quote 0.8, 1.1 and 0.9 TNZO per million tokens with uptime 97%, 99.9% and 99%. " +
"Which gives the lowest expected cost if a failed request must be retried once?",
"standard",
);
console.log(reply.output);
console.log(reply.metadata.loops_used, reply.price_tnzo);| Tier | Use |
|---|---|
fast | Shallow reasoning at the lowest cost |
standard | The default depth |
deep | Long reasoning chains |
institutional | Deep loops with TEE attestation and an on-chain receipt |
3. Bound loops, cost and time
For anything an agent runs unattended, set the limits explicitly. The request is refused if the budget cannot be met, rather than quietly downgraded.
const bounded = await client.cortex.reasonWithRequest({
model_id: MODEL,
input: "Draft a migration plan for moving a nightly batch job to rented GPU capacity.",
tier: "deep",
min_loops: 4,
max_loops: 12,
max_cost_tnzo: 1_000_000, // hard cap, in the smallest TNZO unit
deadline_ms: 30_000,
attestation: "tee",
});attestation: "tee" routes the request only to a worker in a trusted execution environment and puts the TEE quote in the receipt. The same with the CLI:
tenzro cortex reason \
--model-id <cortex-model-id> \
--input "Draft a migration plan for moving a nightly batch job to rented GPU capacity." \
--tier deep \
--min-loops 4 \
--max-loops 12 \
--max-cost-wei 1000000 \
--attestation tee \
--rpc https://rpc.tenzro.xyz4. Read the receipt
Every response carries a receipt signed by the worker:
const r = bounded.receipt;
console.log({
model: r.model_id,
weights: r.weights_hash,
runtime: r.runtime_hash,
loops: `${r.loops_used}/${r.loops_requested}`,
worker: r.worker_did,
tokens: [r.tokens_in, r.tokens_out],
price: r.price_tnzo,
attested: Boolean(r.tee_quote),
});
console.log("settled:", bounded.settled);The receipt commits to the input and the output, so you can prove later which model, weights and runtime produced an answer and what it cost. Settlement charges per token plus per loop actually used, from your account to the worker.
5. Give an agent memory
Agents keep a per-agent memory that recall searches by meaning, by keyword or by both (the default, hybrid). Grant it facts:
const memory = client.memory();
await memory.grant({
agent_did: "did:tenzro:machine:...",
text: "Preferred GPU providers must publish a signed policy and hold a TEE certification.",
source: "controller",
});tenzro memory grant \
--agent-did did:tenzro:machine:... \
--text "Batch jobs may run only between 01:00 and 05:00 UTC." \
--rpc https://rpc.tenzro.xyz6. Reason over what the agent remembers
Recall the relevant records and put them in the request:
const recalled = await memory.recall({
agent_did: "did:tenzro:machine:...",
query: "rules for renting GPU capacity",
k: 5,
});
const context = recalled.records.map((m) => `- ${m.text}`).join("\n");
const plan = await client.cortex.reasonWithRequest({
model_id: MODEL,
input: `Constraints:\n${context}\n\nPropose a rental schedule for a 3-hour nightly job.`,
tier: "standard",
max_cost_tnzo: 1_000_000,
});
console.log(plan.output);List what an agent holds with memory.listRecords(agentDid); archive a record with memory.archive(recordId, agentDid).
Next steps
- Cortex and Agent memory references.
- Build an agent swarm orchestrator: give the orchestrator Cortex for planning.
- Inference: ordinary chat, embeddings and media.