# Prime Agent

> Import Prime Agent sessions, forks, and recursive child sessions. Hansard never reads Prime Agent credentials.

[Prime Agent](https://github.com/PrimeIntellect-ai/prime-agent) saves sessions
as JSONL session trees. Hansard imports ordinary conversations, the branch you
last worked on, forks, and recursive language model (RLM) child sessions. Your
model provider sign-in stays inside Prime Agent.

## Source IDs

| Source        | Use it for                                                                                      |
| ------------- | ----------------------------------------------------------------------------------------------- |
| `prime-agent` | Prime Agent sessions in current and older folder layouts, forks, and linked RLM child sessions. |

## How the import works

Hansard reads Prime Agent's current flat session folder, the earlier folders
for each working directory, and older JSONL files stored directly under
`~/.prime/agent`. Every stable Prime Agent release writes the same version 3
session tree, with added records for session events, repository state, service
tier, child usage, and RLM children. Hansard accepts only this version 3
format. Files in pi's older version 1 and 2 formats are rejected, because
Prime Agent never wrote them.

The conversation starts at the last entry in the file and follows each entry's
parent back to the start, which is the branch Prime Agent resumes. User and
assistant messages, images, reasoning, tool calls and results, model settings,
usage, session events, and repository and status details come from that
branch. Entries on abandoned branches stay in the archive's exact copy of the
file.

RLM child sessions become their own linked conversations, and their usage stays
with the child. Resuming a Prime Agent session updates the same conversation in
Hansard, and a fork creates a new linked conversation. The import reads only
conversation records. It never reads provider credentials, configuration
secrets, or general app logs.

Prime Agent's continual harness, which carries learned state from one session
to the next, is archived as memory instead. `hansard memory backup` saves
`~/.prime/agent/harness/harness_state.json` and the global `refinements.jsonl`
history as editable global memories. A session's own harness state stays in
that session's archived files and does not become a project or global memory.
Session details record only the harness format and its entry and refinement
counts, not its prompts, memories, skills, or subagents.

## Import and keep current

**Import now**

```sh
hansard import --source prime-agent --since all
hansard memory backup
hansard index rebuild
```

Hansard finds the standard `~/.prime/agent` folder. If your sessions are
somewhere else, set `HANSARD_PRIME_AGENT_SESSION_DIR`.

**Keep current**

With **Automatic** source selection, the watcher already includes
`prime-agent`, and it backs up memories every 15 minutes. With a **Custom**
list, enable the source. The watcher picks it up within 30 seconds:

```sh
hansard config sources enable prime-agent
hansard watcher status
```

### Set up Prime Agent first

Install Prime Agent with Prime Intellect's installer, start it, and use
`/login` to connect a model provider:

```sh
curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh
prime-agent
prime-agent model list
```

The [Prime Agent model catalog](https://www.hansard.dev/reference/prime-agent-models/) lists the
model routes bundled with the Prime Agent release Hansard was checked against.
It does not show what your account can use; `prime-agent model list` shows the
routes available on your machine.

## Review the import in the app

1. When the import finishes, open **Conversations** and select **Filter & sort**.
2. Set **Source** to **Prime Agent** and set **Time** to the window you imported. Use **Folder** to narrow the list when you use this harness in several projects.
3. Select a conversation to check its messages, tool calls, files, commits, model, and token usage.

To keep archiving new sessions from a local harness, open **Settings → Imports**. **Automatic** follows every supported harness installed on this computer. **Custom** lets you turn individual harnesses on or off. Cloud sources and account exports never run from here; each needs its own import command. If a conversation you expect is missing after you reset the filters, run the import command on this page again with `--explain-skips` where the source supports it.

## What Hansard preserves

- User and assistant text, images, reasoning, tool calls and results, shell
  commands, model routes, response IDs, finish state, input and output tokens,
  and the cost Prime Agent reported.
- Model, reasoning effort, and service tier changes, applied to the turns that
  follow them.
- Branch summaries, context compaction, session events, tasks, repository,
  branch, commit, and extension details. Abandoned branches stay in the
  archived copy of the file.
- Fork history and linked RLM child sessions, including the child's tokens and
  cost when Prime Agent recorded them.
- A session's own harness state in its archived files, with only the counts of
  prompts, memories, skills, subagents, and refinements in the session details.
- Your images and extension attachments, stored as attachment files instead of
  inside the transcript.

Prime Agent can continue your latest session, resume a session in place, or
fork it. `prime-agent --resume` and `prime-agent --fork` take a session path or
ID:

```sh
prime-agent --continue
```

After a resume, the next import updates the same Hansard conversation. A fork
becomes a separate conversation that records its parent.

## Known limitations

- A route in the model catalog does not mean your account can use it.
- Registry, scheduler, and artifact JSONL files without a valid session header
  are rejected instead of being guessed into conversations.
- Version 1, version 2, mixed, damaged, changing, and oversized session files
  are rejected instead of being read as pi sessions.
- A session's own harness state stays in its archived files. Only the global
  harness appears in memory search.
- Hansard never reads, copies, or archives Prime Agent's `auth.json`, API keys,
  OAuth tokens, configuration, background service logs, or installed package
  files.

> **Supported folder layouts:** Hansard reads the current flat `sessions/*.jsonl` folder, early session trees
> for each working directory, older JSONL files under `~/.prime/agent`, and RLM
> children under `session-artifacts`, including each session's
> `harness/harness_state.json`. To read other folders, set
> `HANSARD_PRIME_AGENT_SESSION_DIRS` or `HANSARD_PRIME_AGENT_HOME`.

## Refresh an existing archive

```sh
hansard import --source prime-agent --since all
hansard index rebuild
```

After a Hansard parser change, reimport from Prime Agent's files. Model routes,
service tiers, session events, attachments, fork history, and harness state all
come from the original JSONL files and session folders. Hansard does not patch
older imported conversations in place.
