AI Tools Developer Tools

Long-Running Agents: How ScaleDown Models Trim Context in Deep Agents

ScaleDown's small task-specific models handle summarizing, compressing and extracting for long-running agents, so a large model is not spent on housekeeping.

Illustration of a long document being trimmed into a compact bundle, representing context management for long-running agents
AI-generated editorial illustration.

An AI agent that works for hours accumulates a lot of baggage: old messages, bulky tool outputs, long documents. Something has to decide what stays in front of the model and what gets shortened. ScaleDown, a set of small task-specific models, now plugs into LangChain and Deep Agents to take over that housekeeping for long-running agents, and it is also supported in the LangSmith LLM Gateway.

LangChain’s blog describes the idea this way: running an agent for a long time comes down to context management, meaning which information goes into the model’s working memory and when. Summarizing old history, shrinking large tool results and pulling the right data out of long inputs are all decisions, and LangChain says those have historically been made by a large language model, which is slow and expensive at the volume a long-running agent produces.

What is ScaleDown, and what does it do for an agent?

ScaleDown offers what LangChain calls constrained decoding models, or CDMs. A general-purpose language model can write any string, one token at a time. A CDM is trained for a single job and can only return answers that job allows, such as a label from a list you supply or passages copied from the input. Because the output space is narrow, the model can be much smaller. LangChain relays ScaleDown’s figure that these models are 200x faster and 467x cheaper than frontier models on such narrow tasks. That figure is ScaleDown’s own claim and applies to narrow tasks, not to general reasoning.

A token is a small chunk of text, roughly a word fragment, and models read and write in these units. Decoding is the step where a model chooses each next token. Constraining that step is what keeps the model focused and cheap.

Which four models does ScaleDown provide?

According to LangChain, each model handles one task:

  • Summarize writes a short summary of long text.
  • Compress cuts a block of context down to the parts relevant to a question.
  • Extract pulls out the fields you describe, each with a confidence score and its position in the source.
  • Classify scores text against labels you define and returns a probability for each, with an optional natural-language reason.

LangChain says every model accepts up to 1 million tokens of input, so a full contract or an hour of agent history fits in one call without splitting it into chunks. Extract, Summarize and Classify also accept images and scanned PDFs directly, so a screenshot or a scanned invoice can serve as input.

How do the pieces fit around the main agent model?

The main agent model still runs the loop. ScaleDown works around it. LangChain’s description of the division of labor: Summarize runs before each model call, Classify runs on the model’s output, Compress runs on tool results, and Extract runs on the user’s message.

The langchain-scaledown package packages three of these roles as middleware for LangChain and Deep Agents. Middleware is a layer that sits between steps of the agent loop and can alter what passes through. One middleware summarizes old history, one compresses large tool results, and one extracts structured data from the conversation. Calls made through the LangSmith LLM Gateway are traced and count toward a team’s spend and rate limits, according to LangChain.

Where does Deep Agents come in?

Deep Agents is LangChain’s agent harness, a ready-made loop that calls tools and adds built-in capabilities for real tasks. LangChain’s documentation lists a virtual filesystem, optional sandbox and code interpreter, subagent spawning, optional task planning, and human approval at critical decision points. Its context management features include skills, memory, summarization, context offloading and prompt caching. Context offloading means moving large results out of the model’s working memory into files so they do not crowd it.

Deep Agents already summarizes history and offloads large results on its own. The ScaleDown integration changes which model performs those summarizing and compressing steps, swapping an expensive general model for a small specialist.

How does this compare with other approaches to context management?

The sources describe two broad ways to keep an agent’s context manageable. The first is to ask the same large model that runs the agent to summarize and trim its own history. It is flexible, but LangChain says it is slow and expensive at scale. The second is the approach profiled here: hand each housekeeping task to a small model trained only for it. The trade-off follows from the design. A specialist is faster and cheaper but cannot do anything outside its one task, so the large model still handles planning and reasoning.

LangChain also notes that ScaleDown’s Classify will feel familiar to anyone who has used a decision model like Jev, since both return a typed answer with a probability. According to LangChain, Jev takes text only and up to 32K tokens of state per question, while Classify takes up to 1M tokens, including images. The sources do not compare ScaleDown with other context-compression tools or with other agent frameworks beyond this.

What does a long-running agent look like with ScaleDown?

Consider a research agent asked to review a stack of scanned supplier invoices and a long policy document over several hours. Following the pattern LangChain outlines, the workflow would run like this:

  • The user’s request arrives and Extract pulls out the fields the agent needs, such as invoice numbers or dates, each with a confidence score and a location in the source.
  • The agent calls tools that return large outputs, and Compress trims each result down to the parts relevant to the question being asked.
  • As the conversation grows, Summarize condenses older history before each new model call so the working memory stays manageable.
  • Classify can score the agent’s output against labels the team defines, such as approved or needs review.

Throughout, the frontier model decides what to do next, while the small models do the repetitive trimming. This example illustrates the division of labor in the source; it is not a reported customer case.

What do ScaleDown’s benchmarks show?

ScaleDown’s own benchmarks, reported by LangChain, compare its models against the average of GPT-5.5, GPT-5.4 Mini and GPT-5.4 Nano on public datasets. In that comparison, Summarize is 41x cheaper and 2.7x faster, and Compress is 138x cheaper and 1.8x faster, with higher accuracy for both. These are vendor-run results relayed in a LangChain post, so they are best read as the vendor’s reported numbers rather than independent measurements.

Limits and cautions in practice

The headline speed and cost figures come from ScaleDown’s own tests on public datasets and on narrow tasks, so results on a team’s own documents and tool outputs may differ. Compressing or summarizing context always risks dropping a detail the agent later needs, which makes it worth testing against real workloads and checking traces in LangSmith before relying on it. The blog post and the Deep Agents documentation are both from LangChain’s own ecosystem, and current public documentation should be checked for pricing, model availability and setup details.

Sources