> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oasm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Context and memory

> How the agent decides what the model sees: the context budget, pruning and compaction, instructions and project files, skills loaded on demand, mentions and page context, short-term and long-term memory, and stored tool output

A model only knows what is in its context window, and the window is finite and paid per token. This page explains how the runtime fills it — and keeps it from overflowing — across a conversation that may run for hours.

```mermaid theme={null}
flowchart LR
    subgraph Always["Every run"]
        P["Prompts<br/>mode + system"]
        I["Instructions<br/>member + project"]
        S["Skill list<br/>names and descriptions"]
        T["Plan + goal"]
    end
    subgraph Memory["Memory"]
        STM["Short-term<br/>Redis, per conversation"]
        LTM["Long-term<br/>opt-in, per member"]
    end
    subgraph History["History"]
        Sum["Summary<br/>from compaction"]
        Msg["Recent messages<br/>pruned to budget"]
    end
    subgraph OnDemand["On demand, via tools"]
        LS["load_skill"]
        RO["read_tool_output"]
        RPF["read_project_file"]
    end
    Always --> W["Context window"]
    Memory --> W
    History --> W
    OnDemand -.-> W
```

## The context budget

The runtime knows each model's context window (from the models.dev catalog, or the member's override on the connection; 128k tokens when unknown) and splits it:

* **30 % is reserved for output**, so a long answer is never cut off by a full input.
* **At 60 %**, the conversation is **compacted**: older messages are summarized into the conversation's summary, and later runs send only the summary plus recent messages.
* **At 80 %**, the history sent with a run is **pruned** first: the oldest messages and verbose tool details go, while the system context and the summary are always kept.

Compaction runs at two moments: after a run whose context passed the threshold, and — in long Agent-mode runs — before each continuation iteration, so a run that keeps working never overflows mid-task. Two triggers for the same conversation join one compaction instead of summarizing twice.

### Keeping tool results small

Every tool result is resent to the model on every later step, so tools return **summary fields, never whole records**. An asset's raw HTTP bodies, for example, would add megabytes per row. Large outputs are cut and paged instead:

* Shell command and connector output is **stored** for one hour. The model sees the first page, and reads further pages with `read_tool_output` when it needs them.
* Fetched web pages are capped at 16 KB of text.
* Attack Surface Query results have their own response-size limit for the agent, much smaller than for the console. See [Attack Surface Query engine](https://docs.oasm.io/architecture/attack-surface-query-engine.md#execution).

## Instructions

Two layers of standing instructions reach the model on every run:

* the **member's instruction** — personal preferences such as language, tone or house rules ([Instruction](https://docs.oasm.io/ai-studio/settings/instruction.md)),
* the **project instruction**, when the chat is locked to a [project](https://docs.oasm.io/ai-studio/project-chats.md).

Project files (up to five per project) are inlined too, each capped and with a cap on their total. When a file is longer than its share, the model sees the beginning and reads the rest with `read_project_file` when it is relevant, so a large reference document does not fill the window.

## Skills

A **skill** is a block of specialist instructions in Markdown — a methodology, a tool's language, a checklist. The prompt carries only each skill's name and one-line description; the model loads the full text with `load_skill` when the task calls for it. Dozens of skills therefore cost a few hundred tokens until one is needed.

* **Built-in skills** ship with the core API, for example how to write Attack Surface Query, reconnaissance and web-application testing methodology, exploit verification, browser automation, building project pipelines, writing Nuclei templates and navigating the console. Several are covered by tests that check every tool name, console route and query in them against the code.
* **Workspace skills** are added by the workspace owner and can be switched on or off. A built-in skill wins over a workspace skill of the same name.
* **Subagents** can load only the skills their definition declares.

See [Skills](https://docs.oasm.io/ai-studio/settings/skills.md).

## Mentions and page context

The console adds two kinds of pointers to a message; the server does not resolve them, the model does, with its tools:

* **Mentions** — typing `@` lets the user pick a target, asset or vulnerability, inserted as `@target:<value>`, `@asset:<value>` or `@vulnerability:<name>`. The system prompt tells the model to look each one up before answering.
* **Page context** — the **Ask AI** side panel appends the console page the user is on (route, path, parameters, title) as the last line of the question. A built-in skill maps every console route to the data and tools behind it, so "what's wrong here?" is answered about the page on screen.

## Short-term memory

Short-term memory is a key-value scratchpad **per conversation**, stored in Redis for 24 hours. The model writes facts it will need again (`stm_write`) — a host's open ports, a credential it found to be invalid, a decision — and they are injected into the context of every later run of that conversation, so they survive compaction. Subagents share their parent conversation's short-term memory, which is how they hand facts to each other without bloating their results.

## Long-term memory

Long-term memory carries knowledge **across conversations**. It is:

* **off by default** — while it is off, the memory tools are removed and saved memories stay out of the prompt,
* **per member** within a workspace — one member's memories never reach another member's runs,
* **written by the model** (`ltm_write`) and reviewable and deletable by the member in [Memory](https://docs.oasm.io/ai-studio/settings/memory.md).

At most the 50 most recently updated records go into the prompt; the model lists the rest with `ltm_read`. Subagents never get long-term memory.

## Related

> [card] [Run lifecycle](https://docs.oasm.io/architecture/ai-agent/run-lifecycle.md)
>
> Where the context is assembled in a run

> [card] [Tools](https://docs.oasm.io/architecture/ai-agent/tools.md)
>
> The tools that read skills, memory and stored output

> [card] [Memory settings](https://docs.oasm.io/ai-studio/settings/memory.md)
>
> Turn long-term memory on and review what is saved


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.