Title: Making the Most of Small Context Windows in Local LLMs
Author: Alex Kirk
Published: November 30, 2026

---

# Making the Most of Small Context Windows in Local LLMs

November 30, 2026

![Illustration of a robot being squeezed by mechanical presses from four directions
while a human offers it a rope.](https://alex.kirk.at/wp-content/uploads/sites/2/
2026/11/llm-under-pressure-1-655x437.png)

Helping local LLMs cope with limited context windows.

I maintain a WordPress plugin called [AI Assistant](https://github.com/akirk/ai-assistant)(
which you can try at [my.wordpress.net](https://my.wordpress.net)) that allows you
to work with your WordPress using local LLMs.

This also works when your WordPress site is hosted elsewhere: while [typical implementations of local AI in WordPress](https://wordpress.org/plugins/ai-provider-for-ollama/)
expect the site to be on your localhost so that it can talk to the LLM server-side,
AI Assistant runs in JavaScript. This allows it to use browser-side HTTP requests
to localhost to talk to [LM Studio](https://lmstudio.ai/) or [Ollama](https://ollama.com/).

While AI Assistant supports talking to cloud providers through [WordPress’s AI Connectors](https://make.wordpress.org/core/2026/03/18/introducing-the-connectors-api-in-wordpress-7-0/),
I wanted to make it work well with local LLMs, which comes with their own challenges.

An important one is the relatively small context window. Local LLMs often run on
hardware that simply doesn’t have as much memory as the servers running models in
the cloud. The larger the context window, the more memory the model needs. So even
if a model supports a large context window, you might only be able to use a fraction
of it on your machine.

Over time I have introduced a number of strategies that I have now compiled a document
inside the AI Assistant repository: [Working with Local LLMs](https://github.com/akirk/ai-assistant/blob/main/docs/working-with-local-llms.md).
I recommend you to read it!

#### Conventional approach

![](https://alex.kirk.at/wp-content/uploads/sites/2/2026/11/Screenshot-2026-11-27-
at-14.39.24-655x226.png)

Keep appending messages until the context window fills up.

#### AI Assistant’s approach

![](https://alex.kirk.at/wp-content/uploads/sites/2/2026/11/Screenshot-2026-11-27-
at-14.39.29-655x353.png)

Actively manage what the model sees, retrieve information when needed, and keep 
intermediate work outside the main context.

### A few highlights from the guide

These are some of the strategies I’ve implemented in AI Assistant. The [full guide](https://github.com/akirk/ai-assistant/blob/main/docs/working-with-local-llms.md)
goes into more detail.

#### Keep the system prompt concise and stable

Every token in the system prompt has an initial impact on the context window already,
so keep it short, but don’t change it between requests.

In anticipation of the user wanting to interact with [the abilities](https://make.wordpress.org/ai/handbook/projects/abilities-api/)
of other plugins, they can [drop short topic hints via WordPress filter](https://github.com/akirk/ai-assistant/wiki/ai_assistant_ability_domains).

#### Keep large tool responses out of the main context

It can happen that a tool call returns a response that is unexpectedly long for 
the model, for example a long blog post. In such a case, AI Assistant will send 
a short preview, keep the tool result in memory, and allow the model to query it
from there via further tool calls.

#### Handle repeated tool calls gracefully

It can happen that the local model re-requests the same tool call again and again
because its context overflows. The default strategy of LM Studio is to “truncate
middle” which then makes the model ask again because the first response was malformed.

In such a case, AI Assistant will pretend the second tool call didn’t happen and
modify its first tool call result with a compact one like above, giving the model
a chance to work with an untruncated response.

#### Stop when the model gets stuck in a loop

Finally, if nothing helps, AI Assistant stops when the model ends up in some sort
of loop. Sometimes, all the tooling can’t help when the constraints of the model
make it impossible for it to fulfil the task.

If you want to read more about this, check the doc [Working with Local LLMs](https://github.com/akirk/ai-assistant/blob/main/docs/working-with-local-llms.md)
inside the [AI Assistant repository](https://github.com/akirk/ai-assistant).

###### Fediverse reactions

Categories: [AI](https://alex.kirk.at/category/ai/), [WP Apps](https://alex.kirk.at/category/wordpress/wp-apps/)

Tags: [LLMs](https://alex.kirk.at/tag/llms/), [WP Apps](https://alex.kirk.at/tag/wpapps/)

Read this next

[WordPress as your Personal Knowledge Base](https://alex.kirk.at/2026/10/01/wordpress-as-your-personal-knowledge-base/)

![Alex Kirk](https://alex.kirk.at/wp-content/uploads/sites/2/2025/06/cropped-2025.
Alex-512x512-1-120x120.jpg)

Alex Kirk

@alex@kirk.at

 **275** posts

 **295** followers

### Leave a Reply 󠀁[Cancel reply](https://alex.kirk.at/2026/11/30/making-the-most-of-small-context-windows-in-local-llms/?output_format=md#respond)󠁿

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Δ

This site uses Akismet to reduce spam. [Learn how your comment data is processed.](https://akismet.com/privacy/)