# Long tasks

> How agents keep going on big jobs - context windows, automatic summarising of earlier steps, the loop detector, and why every stop comes with a reason.

Source: https://docs.teemli.com/agents/long-tasks/

Some work takes an agent hundreds of steps: researching a market, cleaning a spreadsheet, filling in a long form. Teemli is built so these tasks finish, and when one can't, it tells you why.

## No step limit

There's no fixed cap on how many steps or model calls a task may take. Agents keep working until the job is done, you stop them, or a budget is reached.

## The context window

A model can only keep a certain amount of text "in view" at once: its **context window**, measured in tokens (roughly, pieces of words). A long task can outgrow it.

You choose how much each task keeps in view:

- **For the organisation:** **Admin → Models → Context window**: 250k, 500k or 1M tokens. The default is 250k.
- **For one agent:** in its profile, **Context window**: **Organisation default**, 250k, 500k or 1M.

A bigger window lets the agent see more of the task at once, but every step costs more. If the model itself holds less than you chose, Teemli uses the model's limit and says so (for example, "This model holds up to 128k tokens, so 128k is used").

## Summarising earlier steps

When a task fills about 80% of its window, Teemli asks the model to summarise the earlier steps and carries on from the summary. In the task you'll see a step like **Summarised earlier steps to keep going**, with how much was summarised. Choose **Show summary** to read it.

If a provider still says the task is too long, Teemli summarises harder and tries once more.

## The loop detector

Sometimes an agent goes round in circles: opening the same page, running the same command. When Teemli notices, it pauses the task and shows a card:

- **Keep going** if it's making progress you can't see yet.
- **Stop** to end the task.

## Restarts don't lose work

Agent work runs on Teemli's servers. If a server restarts in the middle of a task, another one picks the task up and continues. If that happens over and over for the same task, Teemli stops it to be safe and tells you.

## Every stop has a reason

When a task stops, it says why, in plain words. For example:

| Reason | What to do |
|---|---|
| Stopped: it was repeating itself. | Rephrase the task or break it up. |
| The task got longer than this model can hold, even after summarising. | Pick a model with a bigger context window, or split the task. |
| Its budget for this month is used up. | Raise the agent's budget, or wait for next month. |
| Your plan's usage limit is reached. | Wait for it to reset, or choose another plan, key or your organisation's access in **Settings → Model access**. |
| The AI provider is busy right now. | Try again in a minute. |
| The AI account is out of credit. | Top up your OpenRouter account, or connect another. |
| Teemli restarted several times while working on this, so it stopped to be safe. | **Retry**. |

**Retry** on the task runs it again.

## Tips for big jobs

- Give the whole goal up front, plus what "done" looks like.
- Ask the agent to work in stages and report after each.
- For research across many sources, let it use [sub-agents](/agents/working-together/): each one works in its own task and sends back a short report.
- Set an agent budget you're comfortable with before starting a large job.
