Agents

Memory & Context

Manage long-running context and persistent memory.

Memory & Context

Managing what the agent knows is critical for long-running tasks. Memory comes in two forms: in-context and persistent.

In-Context Memory

Everything in the current context window is available to the model. For short tasks this is sufficient, but for long sessions you need to summarize or truncate older content.

Persistent Memory

Store facts and summaries in a vector database or key-value store and retrieve them at the start of each run. This allows the agent to remember things across sessions.

Context Compression

Use the built-in summarization step to compress earlier turns before they exceed the context limit, preserving important facts while freeing up token budget.

Why context management matters

Every model call has a token budget. For short tasks, this is not a concern. For long-running agents working across large codebases, the context window fills quickly — especially when tool results are verbose. How you manage context directly determines whether your agent stays coherent and useful over a long run.

In-context memory

Everything the agent has seen in the current run is in-context: your original goal, the system prompt, all prior reasoning, every tool call and its result. This is fast and coherent but bounded by the model’s token limit.

Queue automatically manages the context window. When it approaches the limit, it compresses older turns into a rolling summary and keeps the most recent steps in full detail.

Context compression

Queue’s built-in compressor summarizes older conversation turns while preserving key facts. You can configure its aggressiveness in queue.yaml:

context: strategy: rolling_summary max_tokens: 80000 preserve_last_steps: 5

Persistent memory

For agents that run repeatedly on the same codebase, persistent memory lets you store and retrieve facts across sessions. At the end of a run, Queue can extract key findings — architectural decisions, known bugs, file ownership — and store them in a vector index.

On the next run, the agent retrieves relevant memories before starting, giving it background knowledge without burning the context window.

Injecting context

You can inject static context at run start: file contents, API documentation, style guides, architecture notes. Use the context key in your run config or the --context flag on the CLI.

queue run “Refactor the auth module” --context docs/architecture.md --context src/types/auth.ts

RAG over your codebase

For large repos, Queue can index your codebase and use retrieval-augmented generation to pull in the most relevant code snippets at each step. Enable this with indexing: true in your workspace settings. Indexing runs automatically on each commit to the connected repo.

On this page

Create a free website with Framer, the website builder loved by startups, designers and agencies.