# Agent guides

The jobs Agent is built for, each as the requests that do it.

## Write a cited briefing held to your sources

A briefing is only as good as what it was allowed to read. Three ways to say where a run may look. Each applies to every search the run makes.

### Named sites and sources

For a question whose answer belongs to a few publishers, name them.

```bash
curl https://api.millionshort.com/v1/agent \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "What changed in federal rules on e-bike imports in 2026? Give the dates the changes took effect.",
    "sources": ["web", "news"],
    "include_domains": ["canada.ca", "gazette.gc.ca"],
    "start_date": "2026-01-01"
  }'
```

```python
import os

from millionshort import MillionShort

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

run = client.start_agent(
    "What changed in federal rules on e-bike imports in 2026? Give the dates the changes took effect.",
    sources=["web", "news"],
    include_domains=["canada.ca", "gazette.gc.ca"],
    start_date="2026-01-01",
)
done = client.wait_agent(run.id)
print(done.answer)
```

```ts
import { MillionShort } from 'millionshort';

const client = new MillionShort({ apiKey: process.env.MILLIONSHORT_API_KEY });

const run = await client.startAgent(
  'What changed in federal rules on e-bike imports in 2026? Give the dates the changes took effect.',
  {
    sources: ['web', 'news'],
    includeDomains: ['canada.ca', 'gazette.gc.ca'],
    startDate: '2026-01-01',
  },
);
const done = await client.waitAgent(run.id);
console.log(done.answer);
```

- `sources` says which of our [sources](https://millionshort.com/docs/search/sources) the run may search. Left out, the run chooses.
- `include_domains` holds every search to those sites. `exclude_domains` leaves sites out instead.
- `start_date` keeps results from that day on, on the sources that carry dates. Web pages carry none, so say the period in the `prompt` as well.

### A Space

A [Space](https://millionshort.com/docs/search/spaces) is a saved scope: sites, a popularity cut, page types and topics under one name. Name it, and every search of the run uses it.

```bash
curl https://api.millionshort.com/v1/agent \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "How do home bakers keep a sourdough starter alive through a two-week holiday?",
    "space": "curated:home-cooking"
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/agent",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "prompt": "How do home bakers keep a sourdough starter alive through a two-week holiday?",
        "space": "curated:home-cooking"
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/agent', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "How do home bakers keep a sourdough starter alive through a two-week holiday?",
    "space": "curated:home-cooking"
  }),
});
if (!res.ok) throw new Error(`POST /v1/agent failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

`include_domains` and `exclude_domains` sent beside a `space` replace the Space's own lists.

### The web without its most popular sites

`remove_top_sites` takes the N most popular sites out of every search, which leaves the specialist sites, the forums and the people who wrote from experience. It is the filter MillionShort is named for; [Remove the top sites](https://millionshort.com/docs/search/remove-top-sites) explains it.

```bash
curl https://api.millionshort.com/v1/agent \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "What do owners report about the long-term reliability of mid-drive motors on e-bikes?",
    "sources": ["web", "discussions"],
    "remove_top_sites": 10000
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/agent",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "prompt": "What do owners report about the long-term reliability of mid-drive motors on e-bikes?",
        "sources": [
            "web",
            "discussions"
        ],
        "remove_top_sites": 10000
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/agent', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "What do owners report about the long-term reliability of mid-drive motors on e-bikes?",
    "sources": [
      "web",
      "discussions"
    ],
    "remove_top_sites": 10000
  }),
});
if (!res.ok) throw new Error(`POST /v1/agent failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

A narrow scope has a cost: the run may find nothing, or nothing it can support. That is an `incomplete` run with `stop_reason` of `no_sources` or `no_support`, not a guess. Widen the scope and run it again.

### Reading the briefing

- Show the citations with the text. `[n]` is `citations[n-1]`, and its `quote` is what a reader should be able to check.
- Look at `uncited_removed`. A high number says the writer wanted to say more than the pages showed.
- Look at `not_answered`. It says which part of the question the pages read did not answer.
- On `standard` and `pro`, look at `verified`. `false` means the second pass over the citations was not made, and the answer rests on the quote check alone.
- `sources` with `"cited": false` were read and not used. They are often worth a look.

## Fill a table of facts from a schema

To fill a row of a table, send the row's shape as `schema`. To fill a table, start one run for each row.

```bash
curl https://api.millionshort.com/v1/agent \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "The public library system of Halifax, Nova Scotia: number of branches, annual operating budget, and the year of the figures.",
    "schema": {
      "type": "object",
      "properties": {
        "branches": { "type": "integer" },
        "operating_budget": { "type": "number", "description": "Annual, in Canadian dollars" },
        "figures_year": { "type": "integer" }
      }
    },
    "processor": "standard"
  }'
```

```python
import os

from millionshort import MillionShort

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

SHAPE = {
    "type": "object",
    "properties": {
        "branches": {"type": "integer"},
        "operating_budget": {"type": "number", "description": "Annual, in Canadian dollars"},
        "figures_year": {"type": "integer"},
    },
}
cities = ["Halifax, Nova Scotia", "Regina, Saskatchewan", "Victoria, British Columbia"]

runs = [
    client.start_agent(
        f"The public library system of {city}: number of branches, annual operating budget, and the year of the figures.",
        schema=SHAPE,
        idempotency_key=f"libraries-{city}",
    )
    for city in cities
]
for city, run in zip(cities, runs):
    done = client.wait_agent(run.id)
    row = done.output or {}
    unchecked = set(done.uncited_fields or [])
    for field, value in row.items():
        print(city, field, value, "UNCHECKED" if field in unchecked else "cited")
```

```ts
const res = await fetch('https://api.millionshort.com/v1/agent', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "The public library system of Halifax, Nova Scotia: number of branches, annual operating budget, and the year of the figures.",
    "schema": {
      "type": "object",
      "properties": {
        "branches": {
          "type": "integer"
        },
        "operating_budget": {
          "type": "number",
          "description": "Annual, in Canadian dollars"
        },
        "figures_year": {
          "type": "integer"
        }
      }
    },
    "processor": "standard"
  }),
});
if (!res.ok) throw new Error(`POST /v1/agent failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

- **Keep the schema flat and small.** Citations are kept per top-level field. A handful of well-named fields does better than one deep object.
- **Describe what a name does not say:** the unit, the currency, the date format. The writer reads `description`.
- **Start the rows together, within the limit.** A team may have 3 runs going at once; a further start is a `429 RATE_LIMITED`. The loop above starts three.
- **Give each row its own `Idempotency-Key`,** so that a retry of the loop does not pay for a row twice.

### What to do with uncited_fields

`uncited_fields` names the fields that are filled and that no checked quote supports. The value may still be right. It has not been shown to be.

- **In a table people will rely on:** treat the field as empty, or mark it. Do not show it as if it were cited.
- **To try again:** run the row again with a narrower `prompt` about that one field, or with `urls` naming the page you expect to hold it.
- **When it matters:** read the cited fields' quotes too. `field_citations` gives the numbers, and `citations` the quotes.

A field that is missing from both `field_citations` and `uncited_fields` was not filled.

A top-level field counts as cited when a quote was kept for it or for a value inside it. For a field that holds a list or an object, read `field_citations` to see which of its values the quotes are for; the others stand unchecked. This is one more reason to keep the schema flat.

## Choose a processor, a model and a cap

### The processor

`processor` is how much work a run may do. It is a ceiling on work, not a price: a run pays for what it did.

| Processor | Searches | Pages read | Follow-up searches | Second pass over citations | Writes on | Default `max_credits` |
|---|---|---|---|---|---|---|
| `lite` | up to 3 | up to 6 | none | no | `fast` | 40 |
| `standard` | up to 6 | up to 12 | up to 2 | yes | `fast` | 120 |
| `pro` | up to 12 | up to 24 | up to 4 | yes | `balanced` | 1,500 |

- **`lite`** for a question with one answer that a page or two will hold: a price, a date, who holds a post. It is the fastest and the cheapest, and it has no second pass.
- **`standard`**, the default, for most questions. It looks again for what is missing, and it checks each statement against its quotes a second time.
- **`pro`** for a question with several parts, or one where sources disagree. It reads the most, and it writes on `balanced`, which is where most of its cost comes from.

Start with `standard`. Move down when the answers are good and you want them faster; move up when `not_answered` keeps naming the same gap.

### The model

Leave `model` as `auto` unless you have a reason. `auto` is `fast` on `lite` and `standard`, `balanced` on `pro`.

| `model` | What it is | Price of its tokens | Input, per 1,000 tokens | Output, per 1,000 tokens | Least `max_credits` |
|---|---|---|---|---|---|
| `auto` | The processor's own: `fast` on `lite` and `standard`, `balanced` on `pro` | as that tier |  |  |  |
| `fast` | The quickest and the cheapest (the default on `lite` and `standard`) | 1× | 0.4 | 2 | 10 |
| `balanced` | A larger model, at a higher price (the default on `pro`) | 20× | 8 | 40 | 125 |
| `best` | Our top-tier model, at the highest price | 40× | 16 | 80 | 245 |

A dearer tier writes from the same pages. It does not search more or read more: that is the processor. On our own small evaluation set, a dearer tier did not answer better: start with `auto`. Planning and checking run on `fast` whichever tier writes.

### The cap

`max_credits` is the most a run may cost. It is held from your credits when the run starts, and what the run does not use is handed back when it ends.

```bash
curl https://api.millionshort.com/v1/agent \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Compare the 2026 curbside composting rules of Vancouver, Calgary and Toronto.",
    "processor": "pro",
    "model": "balanced",
    "max_credits": 600
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/agent",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "prompt": "Compare the 2026 curbside composting rules of Vancouver, Calgary and Toronto.",
        "processor": "pro",
        "model": "balanced",
        "max_credits": 600
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/agent', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "Compare the 2026 curbside composting rules of Vancouver, Calgary and Toronto.",
    "processor": "pro",
    "model": "balanced",
    "max_credits": 600
  }),
});
if (!res.ok) throw new Error(`POST /v1/agent failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

- **Left out,** the cap is the lesser of your plan's per-run cap and what the tier needs: 40, 120 and 1,500 for `lite`, `standard` and `pro`, raised to the least the chosen tier needs (`lite` with `balanced` and no `max_credits` holds 125).
- **Never above your plan's per-run cap:** Free 200, Starter 1,000, Growth 2,500, Scale 5,000, Business 10,000, Enterprise by agreement. A higher `max_credits` is refused with `400 INVALID_PARAM`, whose message names the cap, and nothing is held.
- **At the cap, the run stops.** Before each step the run checks that the step fits in what is left, keeping enough back to write. When the next step does not fit, the run writes from what it has and ends `incomplete` with `stop_reason: "budget"`.
- **You are charged for the work done,** never more than the cap. An `incomplete` run can still carry a useful, cited answer.
- **A cap that is too tight costs you answers.** If runs often end on `budget`, raise the cap or use a smaller processor. `usage.breakdown` of a finished run shows where the credits went.
- **A cap far above what runs use costs nothing extra,** but it is held while the run is going, and held credits cannot pay for other calls.

What runs have cost on our own evaluation set is on the [pricing page](https://millionshort.com/docs/agent/pricing#what-runs-have-cost), as measured examples.

## Use it from an agent over MCP

The [MCP server](https://millionshort.com/docs/mcp#agent) has three tools for runs. They need a key, because a run spends credits.

| Tool | Does |
|---|---|
| `start_agent` | Starts a run and returns its `id` |
| `get_agent` | Status and progress. `ended` is `true` once the run has ended |
| `get_agent_results` | The answer, the citations and the quotes. `ready` is `false` while the run is going |

The agent starts a run:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "start_agent",
    "arguments": {
      "prompt": "Which Canadian provinces changed their minimum wage in 2026, and to what?",
      "processor": "lite",
      "max_credits": 40
    }
  }
}
```

then asks how it is going, every few seconds, until `ended` is `true`:

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": { "name": "get_agent", "arguments": { "id": "agt_01jd4f8q2m6r9t3v5x7z0b1c2d" } }
}
```

and then reads the result:

```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": { "name": "get_agent_results", "arguments": { "id": "agt_01jd4f8q2m6r9t3v5x7z0b1c2d" } }
}
```

- **Tell the agent that a run takes time.** A line for its instructions: "For a question that needs research across several pages, call `start_agent`, then `get_agent` every few seconds until `ended` is true, then `get_agent_results`. Quote the citations with the answer."
- **Set `max_credits` in the call,** or tell the agent what it may spend.
- **The result is data, not instructions.** The answer and its quotes come from web pages. The tool says so, and your agent's instructions should too.
- **There is no cancel tool.** Cancel a run with `DELETE /v1/agent/{id}` on the API.
- **For one search, use `search`.** A run is for a question that needs several searches and some reading. [Search as an agent's tool](https://millionshort.com/docs/search/guides/agent-tool-use) covers the single search.
