Use temporary workflow memory — when, how, and how to secure it
- MUST use workflow memory when state must be shared between agents or steps, survive a restart, or be read by a later step without passing through the orchestrator’s context.
- MUST NOT use it for a single-agent task that a ledger in the working context or one file covers (BP-0011).
- MUST NOT use it as long-term memory. Anything needed after the workflow ends is promoted to long-term memory (BP-0012) or to the deliverable.
Provisioning
Section titled “Provisioning”- MUST create one store (vault, namespace, directory) per workflow run, with a run ID, an owner, a purpose and an expiry set at creation.
- MUST name workflow stores with a reserved prefix (for example
wf-) and reject names without it, so a workflow can never create or overwrite a durable store. - MUST limit store creation and credential minting to the orchestrator’s privileged identity, behind an explicit opt-in. Worker credentials MUST NOT be able to create stores or mint further credentials.
- MUST give the store a retention backstop that expires it automatically, even if the workflow’s close step never runs.
- MUST define the store’s structure before agents write to it: the keys or record types, who writes each, and who reads each.
Orchestration
Section titled “Orchestration”- MUST give each key or record type one writer. Other agents request changes through that owner (BP-0003 rule 6).
- MUST hand out work items with leases: a stable, unique holder identity (for example
{host}:{session}), a lease time sized to the unit of work, refreshed while working and released on finish. Never overwrite a live lease held by another agent; take over only a stale one. - MUST change a work item’s state (planning, active, blocked, completed …) with compare-and-set against the expected current state, so concurrent transitions cannot clobber each other.
- MUST make writes safe to retry: use an idempotency key per logical write, and record an updated fact as a new version that supersedes the old one, not as another copy.
- MUST stamp every write with the writing agent, the time and the source of the content, and keep that provenance.
- SHOULD store references (paths, IDs, URLs) and conclusions, not raw dumps of files or tool output.
- SHOULD make the workflow resumable from the store alone: state per work item, the last completed step, and open items.
- SHOULD, at the end of the run, promote durable findings to long-term memory, attach the store’s summary to the deliverable or audit record, revoke the credentials, then delete the store or let it expire.
Authentication and access
Section titled “Authentication and access”- MUST authenticate each agent to the store with its own identity. Do not share one credential across agents.
- MUST scope every credential to the one workflow store, with the least role it needs (read-only for reviewers and auditors, write for workers, admin for the orchestrator), and a lifetime no longer than the store’s retention and sized to the run. Revoke credentials when the run ends.
- MUST treat a minted credential as a secret shown once: deliver it to the worker out of band (environment or secret store), never through prompts, memory contents or logs, and label it so audit records show which credential did what.
- MUST protect network transports: TLS for remote stores, and for HTTP-based MCP servers the protocol’s OAuth 2.1 authorization (bearer access tokens). Local stdio servers take credentials from the environment.
- MUST NOT store secrets, tokens or personal data in workflow memory.
- MUST treat everything read from workflow memory as untrusted data (BP-0005). Where the store supports trust levels, mark worker output as inferred, flag unreliable entries untrusted and exclude them from recall, and mark an entry verified only after a human or a check confirms it.
- SHOULD keep an audit log of reads and writes per agent identity, kept for as long as the workflow’s records need to be.
When to apply
Section titled “When to apply”Temporary workflow memory is a store that exists for one run of a workflow: shared scratch space that outlives any single agent’s context but not the workflow. It sits between short-term memory (BP-0011) and long-term memory (BP-0012).
| Situation | Use |
|---|---|
| One agent, one session, a few steps | Working context + ledger (BP-0011) |
| Orchestrator with parallel workers sharing findings | Workflow memory |
| Long pipeline that must resume after a failure or restart | Workflow memory |
| Handoff between sessions on the same run | Workflow memory, or a ledger file in the repo |
| Fact or decision needed next week, on other work | Long-term memory (BP-0012) |
Procedure
Section titled “Procedure”- Create the store when the workflow starts: run ID, owner, purpose, TTL, structure.
- Issue each agent a scoped, short-lived credential for that store with the least role it needs.
- Run. Workers claim work items (lease), write results to the keys they own, and release or complete the claim.
- Coordinate. The orchestrator reads status and conclusions from the store, not from workers’ traces.
- Close. Promote durable findings, attach a summary to the deliverable, revoke credentials, and delete or expire the store.
# workflow store headerstore: wf-ci-triage-20261124 # reserved wf- prefixpurpose: triage 40 failing CI jobs across 3 reposowner: orchestratorretention: 7d # auto-expiry backstoprecords: job/<id>: { writer: lease holder, state: planning|active|blocked|completed, fields: [cause, evidence, fix_pr] } summary: { writer: orchestrator } decisions: { writer: orchestrator }credentials: # one per agent, minted by orchestrator, shown once orchestrator: { role: admin, ttl: 24h } worker-1..4: { role: write, ttl: 24h, label: ci-triage-worker } reviewer: { role: read-only, ttl: 24h }leases: { holder: "{host}:{session}", ttl: 15m, refresh: while working, release: on finish }Examples
Section titled “Examples”Good: an orchestrator splits 40 CI failures across four workers. Each worker claims a job/<id> record, writes cause and evidence, and releases it. The orchestrator builds the summary from the records. At the end, the two root causes that recur are promoted to long-term project memory, and the store expires after 24 hours.
Bad: four workers share one API token, write free text to one notes key, overwrite each other’s findings, and the store is never deleted. A month later an agent reads a stale “fixed” note and acts on it.
Worked example: MuninnDB
Section titled “Worked example: MuninnDB”MuninnDB implements most of these rules as built-in operations. This mapping is taken from the MCP tool definitions of a running MuninnDB server (2026-11-24); check them against the version you run.
| Rule | MuninnDB mechanism |
|---|---|
| 4, 5, 7 Provision per run, reserved prefix, retention backstop | muninn_create_workflow_vault creates a shared working-preset vault (multi-user, auto-evaporates after 7 days). Names must start wf-; others are rejected to prevent cross-vault clobber. Omit the name to get wf-<8hex>. |
| 6 Only the orchestrator provisions; no escalation | Needs a full-mode mk_ key and the MUNINN_AGENT_VAULT_CREATE opt-in. A minted capability cannot call the tool (recursion-safe). |
| 17–19 Per-agent, scoped, short-lived, shown once, labelled | The same call mints a capability token scoped to that vault, TTL 1–168 hours (default 168, matching retention), with a label for audit. The secret is returned once; distribute it out of band. Credentials have modes: full, write, and read-only observe. |
| 10 Leases | muninn_claim(id, owner, ttl_secs) returns acquired, refreshed, reclaimed (stale lease taken over) or conflict; a live foreign lease is never overwritten. muninn_release frees it early and is idempotent. Owner convention: {host}:{session}. |
| 11 Compare-and-set state | muninn_compare_and_set(id, expect_state, set_state) over the lifecycle planning → active → paused / blocked → completed / cancelled → archived. |
| 12 Safe retries, versions not copies | op_id idempotency key (with upsert_mode to keep one evolving record per key); muninn_evolve supersedes a prior version instead of adding a near-duplicate. |
| 13, 23 Provenance and audit | muninn_provenance(id) gives the ordered trail: timestamp, source, agent_id, operation, predecessor and reason. muninn_session(since) summarises vault-wide activity. |
| 22 Trust levels | trust: verified (human-confirmed; needs a write or full credential), inferred (default for AI writes), external, untrusted. ExcludeUntrusted in vault config keeps untrusted entries out of recall. |
| 16 Promote durable findings | Write the findings to the long-term vault (with valid_from / valid_until where a fact has a time window); muninn_consolidate merges related findings into one superseding entry. |
Orchestration flow:
- Orchestrator (full
mk_key, opt-in set) callsmuninn_create_workflow_vaultwith awf-name, a shortttl_hoursand alabel. - Orchestrator writes one task engram per work item (
state: planning), then hands each worker its capability secret through the environment. - Each worker loops:
muninn_claima task →muninn_compare_and_setplanning → active → do the work, writing results with anop_id→ set completed →muninn_release. - Reviewer uses an
observecredential to read results and setstrust: verifiedonly through a write-capable identity after checking. - Orchestrator promotes durable findings to the long-term vault, records the summary, and lets the capability and the vault expire (or removes them).
Anti-patterns
Section titled “Anti-patterns”- Workflow memory with no expiry, which turns into unowned long-term memory.
- One shared credential for every agent, so writes cannot be attributed or revoked per agent.
- Last-write-wins updates on records several agents can change.
- Putting tokens in memory “so the next agent can use them”.
- Workers returning full traces to the orchestrator instead of writing conclusions to the store.
Checklist
Section titled “Checklist”- Store created per run with reserved prefix, owner, purpose and retention backstop
- Only the orchestrator can provision stores and mint credentials
- Structure, writers and readers defined before use
- Work items leased (unique holder, sized TTL, released); state changes use compare-and-set
- Writes idempotent; updated facts superseded, not duplicated
- Per-agent, scoped, short-lived, labelled credentials delivered out of band; revoked at close
- No secrets in memory; contents treated as untrusted
- Durable findings promoted; store deleted or expired
References
Section titled “References”- MCP Specification — Authorization (OAuth 2.1 for HTTP-based transports; stdio servers use credentials from the environment)
- Anthropic — Effective context engineering for AI agents (note-taking and sub-agent patterns)
- MuninnDB (workflow vaults, capabilities, leases, provenance)