Skip to content

Where the write goes

The agent's harness holds the key and makes the write, and the model never sees the key. What that looks like in the three common setups.

The write is one HTTP call with your workspace's key in a header. The question for an agent is which process makes that call. The answer is the same in every setup: the process that runs the agent. The model itself never makes the call.

Why not the model

A key the model can read is a key the model can print, paste into a tool call, or be talked into revealing. A key the model cannot read cannot leave through the model. So the key lives in the harness, the runtime, or a service beside it, and the write is made there, with the agent's name in actorId and the instruction's source in instructedBy. The model never sees the key and never needs to.

The same holds for the fingerprints. Fingerprint the file where the harness keeps it; the model never handles the bytes, and the blinding file stays beside the file.

Three setups

The harness writes. The code that runs the agent loop already sees every tool call and every result. After each action it writes the entry, from the same process, with the key from its own environment. This is the simplest setup and the one to start with.

TypeScript
import { createReadStream } from 'node:fs';
import { writeFile } from 'node:fs/promises';
import { PacSpace, fingerprint, readBlindingFile, writeBlindingFile } from '@pacspace-io/sdk';

// read in the harness; the model never sees it
const pac = new PacSpace({ apiKey: process.env.PACSPACE_API_KEY! });

// Fingerprint a file where it is kept, and keep its blinding file beside it.
// A second call for the same file reuses that blinding file, so a retry sends the same fingerprint.
async function refOf(path: string) {
  const kept = await readBlindingFile(`${path}.pacspace.json`).catch(() => undefined);
  const { ref, blinding } = await fingerprint(createReadStream(path), { blinding: kept });
  if (!kept && blinding) await writeBlindingFile(path, blinding);
  return ref;
}

for await (const call of runAgent(instruction)) {
  // the action happens
  const result = await tools.run(call);
  const file = `runs/${runId}/call-${call.id}.json`;
  // the harness's own copy of what happened
  await writeFile(file, JSON.stringify({ call, result }));

  // then it is recorded
  await pac.records.emit({
    record: `run-${runId}`,
    // your words, at most 120 characters
    title: describe(call, result),
    // lower case letters, digits, and hyphens
    kind: 'tool-call',
    occurredAt: result.at,
    actorId: 'agent-7',
    instructedBy: requestedBy,
    payloads: [await refOf(file)],
    idempotencyKey: `run-${runId}:call-${call.id}`,
  });
}

Put the tool's name in the title and keep kind to your own short list. A tool name such as read_file used as kind is refused with RECORD_CONTENT_INVALID, because kind takes lower case letters, digits, and hyphens only.

A recording tool. The agent has a tool it can call, record_action, and the tool's implementation makes the write. The model decides when to record; the harness decides how, and holds the key. Use this when the agent runs in a framework where you do not control the loop, and pin actorId and instructedBy inside the tool rather than taking them from the model.

A sidecar. A separate service receives the agent's events (from a message bus, a log stream, or the framework's callbacks) and writes them. The agent's process never holds the key at all. Use this when many agents share one workspace, when the agent's runtime is not yours, or when something beside the agent, such as a monitor that can stop it, writes to the same record.

The order of things

Record the action after it happened. occurredAt is the time of the action, and an entry written before the action is a record of an intention. If the write fails, the action still happened; retry the write with the same idempotency key and the same fingerprints until it is queued, and read the history or wait for record.committed to know it landed. See Safety and idempotency.

When the agent must wait for a person, the person's approval is an entry of its own, and the harness can wait for it to commit before the agent acts, so the record shows the approval first. What an agent did shows it.

What the write does not need

No network access from the model. No secrets in the agent's memory. No changes to the agent's prompt. No approval from PacSpace: a records workspace writes with its key, and the entry is committed or fails with a code the harness can read.

What the record shows a reader

The agent appears where you put it: in actorId, sealed with the entry, which a reader sees when you reveal that field. The key appears nowhere in the record, and whoever holds it can add entries to a record but cannot change one. Once committed, no one can change this record, PacSpace included. On a link made before 1 October 2026, the Shared Record also names the key that wrote each entry beside the actor, as two separate facts.