# OpenClaw

> The openclaw-statejar plugin takes OpenClaw's memory slot. It recalls the memory each turn needs, captures your messages with secrets removed, and answers OpenClaw's own memory tools from StateJar.

## What it does

StateJar takes OpenClaw's memory slot (`plugins.slots.memory`).

- **autoRecall.** Before each turn, the agent gets the memory the message needs. StateJar sends the whole state while it is small, and only the fields a question needs once it is large. Every recall names the handle it came from (`shm_…`) and is written to your audit log.
- **autoCapture.** After each turn, your message is queued on your machine with secrets removed: API keys and tokens, private keys, passwords and card numbers. The agent's reply and tool output are never queued.
  - Inside the Gateway, the queue is sent in batches: after three messages, or at session end, compaction, reset and Gateway stop.
  - A one-shot `openclaw agent` run sends it at the end of its turn.

  StateJar extracts typed facts from the messages, refuses a value that fails its type, and keeps a fact said once in a weak form until it is said again. It stores no transcript.
- **Tools.** `memory_search` and `memory_get` (the memory slot's own tools, answered from StateJar), `statejar_remember` and `statejar_forget`.
- **Commands.** `openclaw statejar init | status | search | add | list | forget | export | pause | resume`.

The plugin is `openclaw-statejar` on npm, open source (MIT) in [statejar-integrations](https://github.com/KING-OF-FLAME/statejar-integrations).

## Install

You need OpenClaw 2026.10.5 or later, with Node 24.16 or later.

```bash
openclaw plugins install openclaw-statejar
openclaw statejar init
```

`init` does three things, and never writes your key to OpenClaw's config:

- it selects StateJar for the memory slot;
- it turns on autoRecall and autoCapture;
- it grants the plugin's hooks conversation access, which OpenClaw requires of any plugin that reads a turn.

## Set it up

Make a developer key on the [API keys page](/api-keys) and put it in the environment the Gateway runs in:

```bash
export STATEJAR_API_KEY="sj_live_…"        # macOS, Linux
```

```powershell
setx STATEJAR_API_KEY "sj_live_…"          # Windows: a new terminal picks it up
```

The other options live in `plugins.entries.statejar.config` (`openclaw config set …`):

| Option | Default | What it does |
|---|---|---|
| `scope` | `openclaw` | The scope in your account the plugin reads and writes. A new scope builds on your newest memory. |
| `autoRecall` | `true` | Add the memory each turn needs, as one audited query per turn. |
| `autoCapture` | `true` | Queue your messages and send them in batches. |
| `apiUrl` | `https://api.statejar.com/api/v1` | The REST API the plugin calls. |

If `STATEJAR_API_KEY` is empty, the plugin uses the key that `statejar login` (the `statejar` package on PyPI) keeps.

## Check it works

1. `openclaw plugins inspect statejar --runtime --json` shows the plugin loaded, `kind: memory`, with its four tools.
2. `openclaw statejar status` shows the scope, what is queued, and the last batch's status (202 when accepted).
3. Tell your agent "I'm Kavya, I live in Bengaluru and my laptop budget is 80000 rupees."
4. In a new session, ask "what is my laptop budget?". The answer uses the budget, and `openclaw statejar search what is my budget` prints the memory with its handle.

## What it sends

- **Leaves your machine:** each recall sends the question (your message) to StateJar's query endpoint. Each batch sends your queued messages, with secrets already removed. The agent's replies and tool output are never sent.
- **Stays on your machine:** the queue lives in `statejar/clients/openclaw`, mode 600, beside the credentials file of `statejar login` (`~/.config` on macOS and Linux, `%APPDATA%` on Windows). Its `state.json` holds only counts, times and the last status code.
- **What StateJar stores:** typed facts, never your messages. Every disclosure is in your [audit log](/audit), and deleting your account deletes all of it.
- `openclaw statejar pause` stops recall and capture until `openclaw statejar resume`.

## Troubleshooting

- **Diagnostics say `before_prompt_build` is blocked:** run `openclaw statejar init`, which grants conversation access.
- **"plugin tool name conflict (memory-core)" in the log:** OpenClaw keeps memory-core loaded beside the slot's plugin. StateJar's `memory_search` and `memory_get` are the ones the agent uses; `plugins inspect` lists them under `statejar`.
- **Nothing is recalled:** `STATEJAR_API_KEY` is not set where the Gateway runs. `openclaw statejar status` then says `not set`.
- **`429` in `openclaw statejar status`:** your plan's per-minute or monthly limit ([what each limit counts](/docs/pricing-and-payments.html)). The batch stays queued and is sent later.
