Context Length

Context length is the maximum amount of information an AI model can process within a single interaction.

It is usually measured in tokens and includes the information supplied to the model as well as the model's generated output.

Context length determines how much text, conversation history, source information, instructions, and tool results can be considered at one time.

What Is Context Length?

Every large language model has a limit on how much information it can process in one interaction.

That limit is called the context length.

The available context may include:

  • System instructions
  • User messages
  • Conversation history
  • Uploaded information
  • Retrieved passages
  • Tool results
  • Workflow state
  • Examples
  • The model's generated response

If the total exceeds the model's supported context length, the application must reduce, summarize, retrieve, truncate, or otherwise manage the information.

Context Length vs. Context Window

The terms are often used interchangeably.

Context Window usually refers to the model's available working space.

Context length refers to the size of that space, typically expressed as a number of tokens.

A simple distinction is:

Context window: the space available.

Context length: how large that space is.

How Is Context Length Measured?

Context length is usually measured in tokens.

A token is a unit of text processed by the model.

A token may represent:

  • A full word
  • Part of a word
  • Punctuation
  • A number
  • A symbol

This means there is no exact universal conversion between tokens and words.

Different languages and writing styles can use tokens differently.

What Counts Toward Context Length?

The total context can include several components.

Instructions

System and workflow instructions consume part of the available context.

User Input

The current message is part of the context.

Conversation History

Previous messages may be included to preserve continuity.

Direct Source Information

Documents or other information supplied directly to the model count toward the context.

Retrieved Information

Passages returned by search or retrieval also consume context.

Tool Results

API responses, calculations, or other tool outputs may be included.

Generated Output

The response itself also uses part of the total context budget.

Why Context Length Matters

A larger context length can support more information in one interaction.

This can be useful for:

  • Long documents
  • Extended conversations
  • Multiple source files
  • Complex workflows
  • Large instructions
  • Detailed analysis

A larger context can also reduce the need to retrieve smaller pieces of information in some workflows.

Longer Context Does Not Always Mean Better Context

More context is not automatically better.

Very large context can introduce problems such as:

  • Irrelevant information
  • Conflicting sources
  • Duplicate content
  • Higher processing cost
  • Increased latency
  • Reduced focus
  • More difficult source prioritization

The objective should be to provide the right information, not the maximum possible amount.

Context Length and Long-Context Models

Long-context models are designed to process much larger inputs than earlier language models.

This can be useful when the task requires broad source material.

Examples include:

  • Reviewing long contracts
  • Analyzing reports
  • Using large policy collections
  • Maintaining long conversation histories
  • Comparing multiple documents

Long context changes the architecture options available to an application, but retrieval can still be useful for larger collections or highly targeted questions.

Context Length vs. Retrieval

Retrieval helps select which information should enter the context.

If a source is too large to include in full, the system can search for the most relevant information first.

For example:

  1. The user asks a question.
  2. The system searches a large document collection.
  3. The top relevant passages are retrieved.
  4. Only those passages are placed into context.

This can improve focus while reducing context usage.

Context Length vs. Memory

Agent Memory stores information for possible future use.

Context length controls how much information can be actively available to the model at one time.

Memory can therefore exist outside the current context and be retrieved later.

Context Length and Grounding

Grounding requires relevant source information to be available to the model.

Context length affects how much of that source can be supplied directly.

When the source fits comfortably, direct context may be sufficient.

When it does not, Knowledge Retrieval can identify the most relevant parts.

Context Length in AI Agents

An AI agent may need context from several sources at once:

  • User request
  • Conversation history
  • Agent instructions
  • Retrieved information
  • Tool outputs
  • Workflow state

Context management becomes more important as the workflow becomes more complex.

The agent should receive enough information to make the next decision without being overloaded with unnecessary context.

Context Length in AskHandle

AskHandle can use direct context and retrieval depending on the information source.

AI Answer can use uploaded information directly in context, including up to 200,000 words.

Document Search and Data Search are better suited to larger collections where the system should retrieve only the most relevant information for each query.

This allows workflows to use long context when it is useful without treating direct context as the only information-access method.

Designing Around Context Length

A good context strategy should consider:

  • What information is essential
  • What can be retrieved later
  • What can be summarized
  • Which sources are authoritative
  • Whether duplicate content exists
  • Whether conversation history still matters
  • Which tool results need to remain available
  • How much output space should be reserved

The best context is focused, relevant, and sufficient for the task.