---
title: "How to solve the context size issues with context packing with Docker Model Runner and Agentic Compose"
description: "Context packing works around small local LLMs' context window limits by having a second model summarize the conversation history once an estimated token count crosses a threshold, then replacing the history with that summary."
url: "https://swe.quest/articles/how-to-solve-the-context-size-issues-with-context-packing-with-docker-model-e9177ed63d80433f"
canonical: "https://www.docker.com/blog/context-packing-context-window/"
source: "Docker"
published: "2026-02-13"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["llms","inference","javascript","containers"]
---

# How to solve the context size issues with context packing with Docker Model Runner and Agentic Compose

A post on [Docker](https://swe.quest/sources/docker.md), published 2026-02-13, 7 min read, How-to. Original: [https://www.docker.com/blog/context-packing-context-window/](https://www.docker.com/blog/context-packing-context-window/)

## Summary

Context packing works around small local LLMs' context window limits by having a second model summarize the conversation history once an estimated token count crosses a threshold, then replacing the history with that summary. The example configures Docker Model Runner models in compose.yml, using a Qwen2.5-Coder 3B chat model and Qwen2.5 1.5B as the summarizer. It estimates tokens as characters/4 with a 5120-token trigger, and implements the packing step in a LangChain.js conversation loop. In the demo, history shrinks from 4886 to 153 tokens (about 97% reduction). Raising context\_size helps only partially because not all models support it and generation slows as the context fills.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)

## Prerequisites

- LLM context windows ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- Docker Compose ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))
- LangChain.js basics

## Keywords

Docker Model Runner, Docker Compose, Qwen2.5, LangChain, llama.cpp, context packing

## Related posts

- [Making (Very) Small LLMs Smarter](https://swe.quest/articles/making-very-small-llms-smarter-de3c73ba9f79b97c.md): Docker · 2026-01-16 · Medium · 17 min read · RAG & retrieval, LLMs, AI for coding, Containers, JavaScript
  A 3B-parameter local model (Qwen2.5-Coder-3B, Q4\_K\_M) can become a useful coding assistant for an unfamiliar, recent Go library (Nova) when it is given a small, focused RAG context.
- [OpenCode with Docker Model Runner for Private AI Coding](https://swe.quest/articles/opencode-with-docker-model-runner-for-private-ai-coding-640e2f146435d737.md): Docker · 2026-01-15 · Medium · 8 min read · AI for coding, Inference & serving, LLMs, Containers
  OpenCode can use locally hosted models by pointing an @ai-sdk/openai-compatible provider in opencode.json at Docker Model Runner's OpenAI-compatible endpoint (localhost:12434/v1, with TCP enabled on Docker Desktop).
- [How to Make an AI Chatbot from Scratch using Docker Model Runner](https://swe.quest/articles/how-to-make-an-ai-chatbot-from-scratch-using-docker-model-runner-48eab58e2814218f.md): Docker · 2025-06-03 · Medium · 17 min read · Inference & serving, Observability, LLMs, Go, Containers
  A local GenAI chatbot built on Docker Model Runner, which runs llama.cpp models natively on the host and exposes an OpenAI-compatible API to containers.
- [Run LLMs Locally with Docker: A Quickstart Guide to Model Runner](https://swe.quest/articles/run-llms-locally-with-docker-a-quickstart-guide-to-model-runner-ccfbbb71db5d1485.md): Docker · 2025-04-04 · Medium · 5 min read · Inference & serving, LLMs, Containers, Developer tools
  Docker Model Runner, in beta with Docker Desktop 4.40 on Apple silicon, pulls LLMs packaged as OCI artifacts and serves them through an OpenAI-compatible API backed by llama.cpp.
- [Why and How to Run Local Models in Zed](https://swe.quest/articles/why-and-how-to-run-local-models-in-zed-dea250314afe2e5d.md): Zed · 2026-05-19 · Medium · 5 min read · Inference & serving, AI for coding, LLMs, Developer tools
  Local open-weight models run through LM Studio, Ollama or llama.cpp offer privacy, predictable cost, control and guaranteed availability, at the price of lower capability, fewer tokens per second and smaller context windows than frontier models.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
