---
url: /run/workspaces.md
---
# Workspaces and sessions

A session is one conversation with the harness, kept after the harness exits so that you can continue it, inspect it, or remove it. A run is one start of the harness in that conversation, from `pandra run` or `pandra resume` until the harness exits:

1. Create: `pandra run` creates a session and its first run. A [run in the background](/run/background.md) (`pandra run --detach`) creates one the same way, and so does a run of an agent that a repository declares for its team ([`pandra guild run`](/guilds.md)). A [quest](/quests.md) creates one for each of its steps and checks that an agent carries out.
2. Resume: `pandra resume ab26` starts the session's next run, in the same conversation, named by the first characters of the session's ID.
3. Keep: between runs, the session keeps its workspace, the directory the agent works in, and its conversation, which the harness stores in the session's harness home, the directory Pandra prepares for the harness. It also keeps the agent package and the harness it started with. Each run reads your current configuration.

## Workspaces

The workspace is the directory the agent works in. Choose it per run:

| Option | Workspace | Removed |
| --- | --- | --- |
| (none) | The current directory. | Never. |
| `--workspace DIR` | Another existing directory. | Never. |
| `--workspace new` | A new, empty directory that Pandra creates for the run. To use a directory named `new`, write `./new`. | With the last session that uses it, whatever it contains. |
| `--worktree` | A new Git worktree of the repository that contains the current directory, on a new branch `pandra/<short session ID>` that starts at your current `HEAD`. | With the last session and the branch, unless it may hold work. |

`--workspace new` gives an agent you are trying out a directory of its own to start in, and lets parallel runs work without sharing a directory. At the end of a run, Pandra names a generated workspace on stderr when it is not empty, after the fields that name [the skills the agent loaded](#see-which-skills-the-agent-loaded):

```text
Session:  0a89a97f012a (reviewer)
Skills not loaded:  pandra
Workspace:          /home/me/.local/share/pandra/workspaces/0a89a97f012a
```

`pandra session inspect` shows any session's workspace, such as one the agent left empty.

`--worktree` gives the agent the committed state of the branch you are on, so commit what the agent should see first, and switch branches before the run to start from another. Files tracked with Git LFS and partial clones need a step of their own ([what a worktree leaves out](#what-a-worktree-leaves-out)).

Removing the last session of a generated workspace removes the workspace, whatever it contains, so copy out what you want to keep first. Pandra keeps a worktree, its branch, and its last session when the worktree has uncommitted changes, or commits of the agent that are on no other branch and not pushed. `pandra session remove --force SESSION` removes what was kept.

::: security
A workspace is where the agent starts, not a boundary: the agent runs as you and can reach the rest of your files. `--workspace new` and `--worktree` limit what the agent starts with and what it leaves behind, not what it can reach.
:::

## Sessions

A headless or TUI run creates a session. Pandra prints the session ID before the harness starts, so you have it even if the run then fails.

```sh
pandra ps          # active sessions
pandra ps -a       # all sessions
```

```text
SESSION       NAME  AGENT                     HARNESS      STATUS  LAST RUN   UPDATED
4b1d0e9a2c7f  -     github.com/acme/reviewer  claude-code  idle    completed  2 minutes ago
9f2c4e1a7b3d  -     github.com/acme/reviewer  claude-code  idle    completed  2 minutes ago
```

A session is `creating` at the start of its first run, until its harness has started the conversation, `active` while a run owns it, `idle` when it can be resumed, and `unavailable` when it cannot, such as when its harness can no longer find the conversation. Each run's outcome is `completed`, `failed`, or `interrupted`.

### Resume a session

`pandra resume` continues a session, named by a full ID, a name, or a unique prefix of at least four characters. `--last` picks the most recently active session in the current directory or a generated workspace, and without either, on a terminal, it shows a picker; `--all` widens both to every session:

```sh
pandra resume 9f2c --prompt "I fixed it. Review again."
pandra resume --last --prompt "Summarize what we decided."
pandra resume
```

Give a session a name to find it later. Names start with a lowercase letter or digit and use `a-z`, `0-9`, `_`, `.`, and `-`:

```sh
pandra run github.com/acme/reviewer@v1.2.0 --name pr-12 \
    --prompt "Review PR 12."
pandra resume pr-12 --prompt "Check the new commits."
```

Because a resumed session reads your current configuration, a rotated token or a newly allowed server applies. `--model` and `--effort` on `resume` change the model and the effort for that invocation. A session that another process is using is never resumed.

Inside the TUI, the harness's own commands that start or switch conversations, such as `/new` and `/fork`, create or switch sessions too. When you switch to a conversation that another Pandra process is using, Pandra blocks the first prompt there and the interface says why.

### Stop and remove sessions

Ctrl-C interrupts a headless run: Pandra asks the harness to stop, waits up to 10 seconds, then ends it; a second Ctrl-C skips the wait. The run ends `interrupted`, unless the answer was already printed. `pandra session stop SESSION` interrupts a run the same way from another terminal.

Sessions are kept until you remove them:

```sh
# the session's record and one block per run with its harness, mode, and outcome
pandra session inspect 9f2c
# remove the session when the run ends
pandra run github.com/acme/reviewer@v1.2.0 --rm \
    --prompt "Review the uncommitted changes."
pandra session remove 4b1d
# remove idle and unavailable sessions, after a confirmation
pandra session prune
# unused environments, caches, and downloads, plus what session prune removes
pandra system prune --sessions
```

`--rm` removes the sessions the invocation created, never a session it only resumed. `session remove` and `prune` skip sessions that a running process owns and sessions whose worktree may hold work, and `session remove` then fails with the command that removes them anyway:

```text
error: 1 session was not removed: 4b1d0e9a2c7f: its workspace may hold work: notes.md has uncommitted changes
  To remove the sessions anyway:
    pandra session remove --force 4b1d0e9a2c7f
```

`pandra session remove --force` stops the owning runs and removes the sessions. The current directory, or a directory you gave with `--workspace DIR`, is never removed.

`pandra system prune` removes what nothing uses: agent environments, build caches, cached downloads, and a local project's fetched sources, so the project's next build fetches them again and fails with `--offline`. It asks once, and needs `--yes` without a terminal. It never removes installed harnesses, approvals, registry credentials, local names, references, or sessions without `--sessions`.

## See what an agent did

`pandra logs SESSION`, short for `pandra session logs`, shows what a session's agent did, run by run: the prompts, the agent's messages, its tool calls, and changes of its plan:

```text
$ pandra logs review1
── run ffbd958a  2026-11-17T15:07:14Z  headless  completed  $0.0012
 #1 > Review the auth module.
 #2 I will run the tests first.
 #3 ✗ Bash: cargo test
          auth::compare
      test result: FAILED. 11 passed; 1 failed; 0 ignored
      error: test failed, to rerun pass `--lib`
 #4 ✓ Read: src/auth.rs
 #5 src/auth.rs:42 compares the token with ==, and auth::compare fails.
```

Each run starts with a header: its run ID, start time, mode, outcome, and cost when the harness reported one. A prompt follows `>`, and a tool call follows its status, `✓` completed, `✗` failed, or `…` not ended, with the last lines of a failed call's output. A call that loads a skill shows `Skill: <name>` on every harness. Entries are numbered across the whole session, so a number names the same entry after later runs. Other options choose what to show:

```sh
# entry 3 in full, with the tool call's input and output
pandra logs review1 --item 3
# every failed tool call, in full
pandra logs review1 --failed
# the last 5 entries, or those of the last 10 minutes
pandra logs review1 --tail 5
pandra logs review1 --since 10m
# the entries so far, then those of the running run until it ends
pandra logs review1 --follow
# every entry in full, each output cut at 200 lines
pandra logs review1 --full > review1.log
```

Ctrl-C stops `--follow`, not the run. With `--json`, the log is one JSON object per line ([session logs in JSON](/automate/output.md#session-logs-in-json)). An agent that the session's agent ran with Pandra has a session of its own, which `pandra session inspect` lists among the session's children.

Removing the session, also with `--rm`, removes its log, so save what you want to keep first, such as with `pandra logs SESSION --full > FILE`.

::: security
The log holds whatever the agent read and wrote, and Pandra hides nothing in it: a secret the agent printed appears in the log, and so do instructions planted in a file or page the agent read, which reach any agent that reads the log.
:::

## See which skills the agent loaded

An agent decides itself when to load a skill, so it can skip one its task needs. At the end of a headless or TUI run, fields on stderr name the skills the session's conversation preloaded, loaded, and did not load:

```text
$ pandra run . --headless --name review1 --prompt "Review the diff."
✓ Built reviewer 0.1.0 · 0.0s
✓ Prepared · 0.0s
  Session:  6d5718ec77d6 (reviewer)
✓ Started claude-code 2.1.285 · 0.5s
✓ Ran reviewer · 12s
No blocking problems in the diff.
  Skills preloaded:   review
  Skills loaded:      review
  Skills not loaded:  pandra, simplify
```

* `Skills preloaded:` lists the [preloaded skills](/configure/instructions-and-skills.md#preload-the-skills-every-run-needs), which the agent has in its instructions from the start.
* `Skills loaded:` lists each skill the conversation loaded, as `Skill:` shows it in [the log](#see-what-an-agent-did).
* `Skills not loaded:` lists the other skills the run installed, including Pandra's own skill `pandra` when the run added it.

`-q` and `--json` leave the fields out; with `--json`, the `result` event has the lists as `skills` ([the event stream](/automate/output.md#the-event-stream)). `pandra session inspect` shows the lists of each run under a `Skills` heading, where `loaded` is split into `this run`, the skills the run loaded, and `earlier`, the other skills the conversation loaded before the run.

## What a worktree leaves out

When Pandra creates a worktree, it fetches nothing and runs none of the repository's hooks or filter drivers:

* Files tracked with Git LFS arrive as pointer files. Run `git lfs pull` in the worktree when the agent needs them.
* In a partial clone that lacks some files of your `HEAD`, the run fails with Git's `could not fetch ... from promisor remote`. To fetch those files first, run this in the repository:

  ```sh
  git diff --binary --no-ext-diff --no-textconv --no-relative "$(git hash-object -t tree /dev/null)" HEAD -- > /dev/null
  ```
