# Export

> Exporting a development session: Markdown for reading and JSON with all messages; what the file contains, an example, what is left out, how it is audited.

An open session has two buttons in its header: **Markdown** and **JSON**. The file is called
`buff-code-<session id>.md` or `.json`. The whole session is exported, not just the part loaded into
the feed; service calls are always included.

## Markdown — for reading

The whole session history as text: a heading from the first line of the developer’s first message,
the developer, the device, the project, the start, the number of turns, the amount charged and tokens by type;
then, in order:

- **Developer:** the message;
- **Buff Code — time · model · tokens:** the model’s reasoning, the answer, each action —
  verb, object, the tool’s technical name, the arguments and the result in code blocks —
  and the turn’s errors;
- service calls are marked “(service call)”;
- a tool’s answer whose call did not make it into the record — as a “Tool output” block.

This is how the start of the file looks (a two-turn session from the English workspace; the values are illustrative):

````markdown
# Why does test_orders fail?

Developer: alice · device alice’s laptop · project shop-web
Started: 2026-09-24T10:12:03+00:00 · turns: 2 · charged: 3.40 ₽
Tokens: 18,240 input · 612 output · 0 reasoning · 9,100 cache read · 0 cache write

**Developer:**

Why does test_orders fail?

### Buff Code — 2026-09-24T10:12:05+00:00 · gpt-5 · 9,120 input · 96 output · 0 reasoning · 0 cache read · 0 cache write

**Ran** `pytest tests/test_orders.py -q` (`bash`):

```
{
  "command": "pytest tests/test_orders.py -q",
  "description": "Run the failing test"
}
```

Result:

```
F                                                                        [100%]
FAILED tests/test_orders.py::test_total - AssertionError: 100 != 90
Command exited with code 1
```

### Buff Code — 2026-09-24T10:12:19+00:00 · gpt-5 · 9,120 input · 516 output · 0 reasoning · 9,100 cache read · 0 cache write

The test expects the total with the discount, but `total()` does not apply it — fixing.

**Edited** `src/orders.py` (`edit`):

```
{
  "filePath": "src/orders.py",
  "oldString": "    return sum(i.price for i in items)",
  "newString": "    return sum(i.price for i in items) - discount"
}
```

Result:

```
Edited src/orders.py
```
````

It is suitable for attaching to an incident review, sending to a colleague or putting into the knowledge base.

## JSON — the whole session as data

An object with three fields:

- `session` — the session description: identifier, organisation, project, login, device, start
  and last change, number of turns, model, first message, tokens by type, duration and
  amount;
- `note` — an explanation of the file’s contents;
- `messages` — the session’s messages in order, as Buff Code recorded them. Each has its number in
  the session (`id`), who speaks (`role`: the developer or the model), the time, a service flag
  (`service`) and parts (`parts`): text, reasoning, a tool call with arguments
  (`tool_call`), the call result (`tool_result`), an error. A model answer has `answer_of`: the turn
  that produced it — model, status, duration, tokens by type and the amount charged.

It is suitable for your own analysis: count tool calls, break down typical questions,
load it into a SIEM.

## What the export leaves out

- the system prompt and the tool descriptions that Buff Code adds to every request —
  neither in Markdown nor in JSON (see [what is not shown](/en/docs/buff-code/sessions#what-is-not-recorded-and-what-is-not-shown));
- files on the developer’s disk that were not passed to the model;
- connection secrets — they are not in the record in the first place.

## Audit log

Every export — of your own or someone else’s session — is recorded in the [audit log](/en/docs/audit-log)
as a “Development session exported” event: who, whose session, when, from which address. More —
[Audit log and Buff Code](/en/docs/buff-code/sessions/audit).

## Local export from Buff Code

Buff Code itself has `buff session export` — a local copy of the session from the developer’s
machine, in Buff Code’s format. It has nothing to do with the records in the workspace: the workspace
keeps what passed through the server, and the developer cannot change that record.
