Ellipsis keeps every record a [session](/docs/sessions) produces and every request it makes to GitHub and the Agents API, so you can check what an agent did and what it cost.

## When to use

Read these records when you need to check what an agent did after it ran.

## Reading a session's records

Ellipsis stores a session's records in order. They hold the messages you sent, the output of the environment's setup, and the harness's own output with every tool call and its result unchanged. [List records](/docs/api/sessions/get-sessions-id-records) to read them after the session ends, or [stream them](/docs/sessions#following-the-work) while it runs. A record that calls a tool names it in `tools`, whichever harness ran the session. [Session events](/docs/api/session-events) describes every record type.

For example, print each tool the model called in last night's session of `test-repair`, an [agent](/docs/agents) that fixes a failing test in `api-repo` and opens a pull request.

```python
from ellipsis import Ellipsis

client = Ellipsis()
for record in client.sessions.records.list("your-session-id"):
    if record.tools:
        print(record.created_at, record.tools)
```

```typescript
import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis();
const records = await client.sessions.records.list('your-session-id');
for await (const record of records) {
  if (record.tools) {
    console.log(record.created_at, record.tools);
  }
}
```

```bash title="CLI"
el session record <session-id>
```

**A session's records are gone**

Ellipsis deletes a session's messages and records when their [retention period](/docs/security#data-retention) ends and keeps its status, cost, and tokens. [Download the session](#downloading-a-session) before then to keep a copy.

## Checking what a session did on GitHub

Ellipsis records every request a session makes to GitHub, git pushes included, and to the Agents API. [List network requests](/docs/api/sessions/get-sessions-id-network) to read each request's method, path, `status`, and duration, and the first 128 KB of its request and response bodies.

For example, print each request the `test-repair` session made, including its push and the pull request it opened.

```python
for request in client.sessions.network.list("your-session-id"):
    print(request.method, request.path, request.status)
```

```typescript
const requests = await client.sessions.network.list('your-session-id');
for await (const request of requests) {
  console.log(request.method, request.path, request.status);
}
```

**A request returned 403**

The request fell outside the session's [permissions](/docs/permissions), and its `response_body` explains why. Add the rule to the agent so its next session can make the request.

## Downloading a session

[Download a session](/docs/api/sessions/get-sessions-id-download) to keep its complete history past its [retention period](/docs/security#data-retention) or to load it into your own log store. Ellipsis returns the history as gzip parts with short-lived URLs. Fetch them in order and join them into one `.jsonl.gz` file with one record per line and the harness output unchanged.

For example, save the `test-repair` session as `session.jsonl.gz`.

```python
from pathlib import Path
from urllib.request import urlopen
from ellipsis import Ellipsis

client = Ellipsis()
log = client.sessions.download("your-session-id")
parts = [urlopen(segment.download_url).read() for segment in log.segments]
Path("session.jsonl.gz").write_bytes(b"".join(parts))
```

```typescript
import { writeFile } from 'node:fs/promises';
import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis();
const log = await client.sessions.download('your-session-id');
const parts = [];
for (const segment of log.segments) {
  const response = await fetch(segment.download_url);
  parts.push(Buffer.from(await response.arrayBuffer()));
}
await writeFile('session.jsonl.gz', Buffer.concat(parts));
```

```bash title="CLI"
el session export <session-id> --gzip -o session.jsonl.gz
```

**The download is missing the newest records**

Ellipsis adds records to the download shortly after the session writes them. While `has_more` is `true`, download the session again later for the rest.

## Finding sessions

[List sessions](/docs/api/sessions/get-sessions) by agent, status, time, repository, source, label, and annotation. Labels and annotations go in an agent's `ellipsis.metadata`, and every session the agent starts carries them. They never change how a session runs. When you start a session from your code, pass `metadata` to add your own.

For example, annotate `test-repair` with the team that owns it.

```yaml fragment
ellipsis:
  kind: agent
  name: test-repair
  metadata:
    annotations:
      team: api
```

List this week's sessions of the API team's agents that ended in an error.

```python
sessions = client.sessions.list(
    days=7,
    annotation=["team:api"],
)
for session in sessions:
    if session.error:
        print(session.id, session.error.reason)
```

```typescript
const sessions = await client.sessions.list({
  days: 7,
  annotation: ['team:api'],
});
for await (const session of sessions) {
  if (session.error) {
    console.log(session.id, session.error.reason);
  }
}
```

## Tracking what agents cost

Each [session](/docs/api/sessions/get-sessions-id) reports its `cost` and `tokens` so far, and each message's [`message_ended` record](/docs/api/session-events#message_ended) reports what answering it cost. [Agent metrics](/docs/api/agents/get-agents-id-metrics) give each finished session's duration, cost, and tokens over a window you choose, and the agent's spend against its [budget](/docs/budgets) over the past 1, 7, and 28 days. Amounts are in millicents, 100,000 to the dollar. [Usage](/docs/pricing#reading-usage) reports your account's costs for a month.

For example, print what `test-repair` spent against its limit over the past 1, 7, and 28 days.

```python
from datetime import datetime, timedelta, timezone

now = datetime.now(timezone.utc)
metrics = client.agents.metrics(
    "test-repair",
    start=now - timedelta(days=7),
    end=now,
)
for spend in metrics.spend_windows:
    print(spend.window_days, spend.spent, spend.limit)
```

```typescript
const now = Date.now();
const metrics = await client.agents.metrics('test-repair', {
  start: new Date(now - 7 * 86_400_000).toISOString(),
  end: new Date(now).toISOString(),
});
for (const spend of metrics.spend_windows) {
  console.log(spend.window_days, spend.spent, spend.limit);
}
```

```bash title="CLI"
el agent metrics test-repair --since "7 days ago" --until today
```

## Receiving alerts

Ellipsis raises an alert when spending nears a limit, credit runs low, or an agent breaks. It posts each alert to your Slack [operations channel](/docs/integrations/slack#operations-channel) and emails the contacts listed under `notifications` in your [account settings](/docs/api/account/patch-account-settings). [List alerts](/docs/api/alerts/get-alerts) to read them from your code.

| Alert | When it fires |
| --- | --- |
| `budget_threshold` | Account spend crosses an alert percentage of an account limit, 80% and 100% by default. |
| `budget_blocked` | A spend limit blocks new model requests. |
| `credit_low` | Your credit balance falls below a threshold while automatic recharge is off. |
| `credit_exhausted` | Your credit balance runs out. |
| `agent_config_broken` | An agent file fails validation, and Ellipsis keeps the last valid definition. |
| `agent_failing` | An agent's session ends in an error. Ellipsis alerts again only after a later session succeeds. |

For example, print the account's alerts, newest first.

```python
for alert in client.alerts.list():
    print(alert.created_at, alert.type, alert.title)
```

```typescript
for await (const alert of await client.alerts.list()) {
  console.log(alert.created_at, alert.type, alert.title);
}
```

## Auditing API use

The [API request log](/docs/api/account/get-account-api-requests) lists every request made with an API key, the CLI, an MCP client, or a session, newest first, with its operation, status code, and the credential that sent it. Ellipsis keeps it for 90 days. The [audit log](/docs/api/account/get-account-audit-log) lists changes to limits, webhooks, the GitHub App installation, credit, refunds, automatic recharge, and the platform fee.

For example, print the requests Ellipsis refused for a missing or insufficient credential.

```python
requests = client.account.api_requests.list(
    status_code=[401, 403],
)
for request in requests:
    print(request.created_at, request.operation, request.status_code)
```

```typescript
const requests = await client.account.apiRequests.list({
  status_code: [401, 403],
});
for await (const request of requests) {
  console.log(request.created_at, request.operation, request.status_code);
}
```
