# Infinity Context

> Trim live prompt history and query older messages on demand, so conversation length is not bounded by the context window.

Source: <https://everruns.com/docs/capabilities/infinity-context/>

|                  |                    |
| ---------------- | ------------------ |
| **ID**           | `infinity_context` |
| **Category**     | Optimization       |
| **Features**     | None               |
| **Dependencies** | None               |

Limits the live prompt to recent conversation history while keeping older messages accessible through `query_history`.

This is useful for long-running sessions where the agent should stay responsive without losing access to earlier decisions, identifiers, or requirements.

## Tools

| Tool            | Purpose                                                      |
| --------------- | ------------------------------------------------------------ |
| `query_history` | Search or retrieve earlier messages from the current session |

## How It Works

1. A message filter caps the number of recent messages sent to the model.
2. If older messages are excluded, the model sees a system notice telling it to use `query_history`.
3. The `query_history` tool can keyword-search history or fetch a specific absolute message range.

## Configuration

Default configuration:

```json
{
  "capabilities": ["infinity_context"]
}
```

Custom budget:

```json
{
  "capabilities": [
    {
      "ref": "infinity_context",
      "config": {
        "context_budget_tokens": 80000,
        "min_recent_messages": 12
      }
    }
  ]
}
```

| Field                   | Type    | Default  | Description                                                   |
| ----------------------- | ------- | -------- | ------------------------------------------------------------- |
| `context_budget_tokens` | integer | `100000` | Approximate token budget reserved for message history         |
| `min_recent_messages`   | integer | `10`     | Minimum recent messages to keep even when the budget is tight |

## Limitations

* Search is keyword-based, not semantic
* The tool reads full session history; it does not currently restrict itself to only the trimmed portion
* Budgeting uses a heuristic message-count estimate, not model-specific tokenization

## See Also

* [Context Compaction](https://everruns.com/docs/advanced/compaction/), Complementary capability that reduces the size of messages in the prompt; see [Worker Harness Defaults](https://everruns.com/docs/advanced/compaction/#worker-harness-defaults) for how they work together
* [Capabilities Overview](https://everruns.com/docs/capabilities/)
* [Harnesses](https://everruns.com/docs/features/harnesses/)