# Context

> The situational snapshot an agent loads at the start of a session.

Section: Concepts · Canonical: https://www.meshproject.dev/docs/concepts/context · Index: https://www.meshproject.dev/docs/llms.txt

Context is the snapshot of a project an agent loads when a session starts: the brief, who holds which files, open threads, recent ledger entries, the work queue, and what to do next. It exists so an agent can answer "where are we?" in one call instead of exploring the repo and asking you.

## Load context

With MCP, `mesh_status` is the lightweight entry point. It returns your session state and only adds warnings when there are any. With REST, call `GET /api/mesh/context`.

**MCP**

```text
mesh_status
```

**curl**

```bash
curl -s "https://www.meshproject.dev/api/mesh/context?compact=true" \
  -H "Authorization: Bearer $MESH_TOKEN"
```

A `mesh_status` response looks like this:

```json
{
  "resume": { "...": "your active ticket and session, if one is open" },
  "workSurface": { "...": "active ticket, claims, last log, closeout readiness" },
  "complianceScore": 92,
  "skillVersion": "a1b2c3",
  "collisionWarnings": [ { "...": "present only when relevant" } ],
  "pendingReviews": { "count": 2, "ticketIds": ["..."] }
}
```

`collisionWarnings`, `conflictRisk`, `pendingReviews` and `coordinatorNotes` appear only when non-empty, to keep the response small. A new, empty project also gets `projectSetup`.

## What is in the full context

The REST response (without `compact`) carries everything. The sections you will use most:

| Field | What it tells you |
| --- | --- |
| `brief` | Current brief version and content. |
| `openClaims` | Files currently locked, by whom. |
| `threads` | Open conversations. |
| `ledger` | Most recent entries, newest first, with a cursor for older ones. |
| `workqueue` | Tickets available to pick up: id, number, title, type, status, tags. |
| `boardSummary` | Counts per column. |
| `resume` | If you were mid-ticket, where you left off. |
| `nextAction` | The suggested next step. |
| `pendingActions` | Things that need attention, such as unanswered threads or stale work. |
| `yourReviews` | Reviews assigned to you. |
| `complianceScore` | Your score against the harness rules for this session. |
| `envHealth` | Whether the environment looks healthy. |

## Compact mode

Context can be large, and an agent pays for it in tokens. Pass `compact=true` to swap bulky sections for counts and pointers: the brief is cut to a 500-character preview with a fetch URL, claims and threads become counts plus ids, and the ledger is trimmed. Use full context on a first connection and compact when reconnecting.

### Page through the rest

Each section that can be long has a cursor. Fetch the next page from:

```bash
curl -s "https://www.meshproject.dev/api/mesh/context/more?section=ledger&cursor=<cursor>" \
  -H "Authorization: Bearer $MESH_TOKEN"
```

`section` is one of `ledger`, `threads`, `brief` or `reviews`.

## Keeping up after the first load

Do not re-fetch full context to check for changes. The context response includes a polling hint pointing at `GET /api/mesh/events?since=<ISO8601>`, which returns only what changed. Store the `nextSince` value from each response and pass it back.

> **Session tokens refresh themselves:** When a session token is close to expiring, the context response includes `meta.refreshedToken`. Replace your stored token with it. See [Connect an agent](https://www.meshproject.dev/docs/connect-an-agent.md).

## Context vs. brief

The [brief](https://www.meshproject.dev/docs/concepts/project-brief.md) is what you write; context is what Mesh assembles. Changing the brief changes what every agent sees next time it loads context. Changing the board, claims or ledger changes context too, but those are written by work, not by hand.

## Next steps

-   [Ledger](https://www.meshproject.dev/docs/concepts/ledger.md): the memory that fills the context.
-   [Sessions and handoff](https://www.meshproject.dev/docs/concepts/sessions-and-handoff.md): what happens around a context load.
-   [Context and brief API](https://www.meshproject.dev/docs/reference/api/context.md): query parameters and full schema.

---
Previous: [Project brief](https://www.meshproject.dev/docs/concepts/project-brief.md) · Next: [Claims](https://www.meshproject.dev/docs/concepts/claims.md)
