> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/technical-reference/models-agents-and-skills/instructions-context-and-token-limits.md).

# Instructions, Context, and Token Limits

A model’s context contains the instructions and data it can use for one request. Instructions, conversation history, retrieved passages, and tool results compete for that context.

{% embed url="<https://1957915746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2FtkGPd30SSD1ANLoG2wq6%2Finstructions-context-and-token-limits.mp4?alt=media&token=95816ea0-ee7c-447c-a168-c00a710d7439>" %}
A short walkthrough of instructions, context, and token limits.
{% endembed %}

## Before you begin

A model selected for the node and access to its prompt and context settings.

## Context and tokens

| Term           | Definition                                                                                                                                                |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Context window | The amount of information a model can consider for a request. Instructions, history, source passages, and tool results compete for this capacity.         |
| Token          | A unit used by a model to process text or other supported input and output. Token counts do not map to a fixed number of words across content and models. |
| Tool result    | The returned data or error from a tool operation. The agent should base its report on this result rather than assuming the call succeeded.                |

## Configuration options

| Option       | Purpose                                                              | Behavior                                                                             |
| ------------ | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| Instructions | Directions that define the task, constraints, and expected response. | Keep them distinct from source text or tool results used as evidence.                |
| Output limit | A cap on generated response length.                                  | Reaching it can truncate the response; it does not increase available input context. |

## Prepare instructions and context

1. Write a clear task instruction and define the required response.
2. Map only the source material needed for the request.
3. Inspect long conversations and large tool results when the model omits details or reaches a limit.

<figure><img src="https://1957915746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2FOr070tjuIKnN8lBG51yP%2Fanswer-format-and-limits.png?alt=media" alt="Answer format and limits controls in StackAI" width="800"><figcaption><p>Max Output Length limits the generated response. It is separate from the model’s context window, which must accommodate the input and other context. Increasing the output limit does not make an oversized input fit. Check the selected model’s supported limits before changing either setting.</p></figcaption></figure>

The model receives the required task and evidence within its supported context.

## Behavior and limitations

Context limits and output limits are different. Increasing the output limit does not create more room for input. Older conversation content can be omitted when the request reaches the model’s context limit. Stored history can therefore contain messages that the model does not receive for every answer.

## Related resources

[Model Settings and Supported Capabilities](https://docs.stackai.com/technical-reference/models-agents-and-skills/model-settings-and-supported-capabilities.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/technical-reference/models-agents-and-skills/instructions-context-and-token-limits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
