# Agents that regrow their context.

> An agent runtime for products. One long-lived agent per customer, your backend as its world, and a database's discipline about context.

Source: https://newt.julianbouchard.com/

Newts regrow what they lose. So does this: every turn strips the context back and grows it again from your app's state and the history, so stale reads never pile up and the prompt cache stays warm.

## How it works

1. **Your app posts an event.** "The person wrote", "the order shipped". newt answers in milliseconds and runs a turn.

2. **newt builds the prompt from your state.** Your app serves the agent's instructions and the customer's state as text pages. When a tool changes something, the page goes stale and the next read fetches it fresh.

3. **Tools act, history keeps what was done.** Reads are dropped at the end of the turn. Writes keep a summary. Messages and payments go through a journal, so a crash never sends twice.

## Why it holds up over months

### Append, never rewrite

Each turn's prompt is the previous one plus a suffix, so the provider's prefix cache covers everything before it.

### Retention classes

Every tool says what survives the turn: `ephemeral` reads are dropped, `durable` writes keep a summary, `outward` effects are journaled.

### A reactive workspace

Tools mark pages stale by key, and the next read fetches them again. The agent never acts on a copy it knows is out of date.

### Exactly-once outward calls

An intent entry reaches Postgres before every outward call, and the call carries a stable idempotency key.

### Compaction that keeps promises

The agent writes its own checkpoint. newt refuses one that drops an open commitment. Raw history is never deleted.

### One binary plus Postgres

Leases, `LISTEN` wakeups and sweeps let any instance run any session. Bring your Postgres, or let newt run its own.

## Try it without an API key

A fake model answers, so all you need is Docker.

```sh
docker compose -f deploy/compose.yaml up --build -d
curl -X POST localhost:7878/v1/agents/assistant-mcp/sessions/ana/events \
-H "Authorization: Bearer demo-token" -H 'content-type: application/json' \
-d '{"id":"m1","text":"Remind me to call the bank tomorrow."}'
curl -N localhost:7878/v1/agents/assistant-mcp/sessions/ana/live -H "Authorization: Bearer demo-token"
```

## Read next

- [Quickstart](https://newt.julianbouchard.com/quickstart/): Run the demo assistant and watch a turn live.
- [How a turn works](https://newt.julianbouchard.com/how-a-turn-works/): From event to commit, and what survives.
- [Context provider](https://newt.julianbouchard.com/context-provider/): The three endpoints your app serves.
- [Tools over MCP](https://newt.julianbouchard.com/tools/): Tag a tool with what it leaves behind.
