I work with my AI agent all day, and some chats run for hours. At some point the answers get slower, a bit vaguer, and details from the start of the chat are gone. Usually I only noticed when something went wrong.

The cause is simple. Every chat has a context window, and before it is full, the agent compacts the conversation into a summary. A summary keeps the gist, not the details.

So I built a plugin that tells me early enough to start a fresh chat, and gives me everything I need to continue there.

What chat-length does

chat-length is a plugin for Hermes Agent, the open source agent by Nous Research. When a chat crosses a threshold, the agent appends a short notice to its normal answer:

Heads-up: this chat is getting long (about 72 % of the way to automatic compaction). Replies get slower and less precise from here on. Best to open a new chat and paste this opener:

Continue our chat "Summer party in Cologne" (session 20261015_141559_2a617f). First retrieve the history yourself with session_search (session_id 20261015_141559_2a617f). Status: * Beach theme chosen * Decoration, tech and catering budget roughly planned Open: venue, bad-weather plan. 

I paste the opener into a new chat. Hermes keeps every session searchable, so the new chat looks up the old one itself with its built-in session_search tool. No handover document, no copy and paste of long summaries.

There are two levels, 70 % and 90 % by default. Each one appears exactly once per chat.

Measured against compaction, not the full window

This was the first thing I got wrong. Hermes compacts by default at 50 % of the context window. A warning at 70 % of the full window would never appear, because compaction comes first.

So the plugin measures against the compaction point: 70 % means "70 % of the way to compaction". If you prefer the full window, set basis: window.

Real numbers instead of guesses

Counting tokens yourself is always a bit off. chat-length uses what the provider actually reports after every model call: prompt tokens including cache, and output tokens. Before the next turn it adds the last reply and the new message.

Without a measurement, for example in the first turn after a restart, it simply waits one turn.

Prompt caching stays intact

A plugin that changes the system prompt would break prompt caching and make every following turn more expensive. chat-length never touches the system prompt.

The instruction goes, for one turn only, into that turn's user message through the regular hook channel. Hermes stores exactly the bytes it sent and replays them unchanged. I checked this with request dumps: in the following turn every earlier message was byte-identical, and the system prompt never changed.

Where it works

It runs on the server side, so it works wherever Hermes answers: CLI, WebUI, the desktop app, Telegram and the other gateways. Background jobs like cron, subagents and batch runs never get a notice.

Install

hermes plugins install MadeByBrain/hermes-chat-length --enable hermes gateway restart 

It needs Hermes Agent v0.21.6 or newer and only the Python standard library. It is listed in the official Hermes plugin catalog and is checked every week against the latest Hermes release.

What it stores

No network calls, no tools. Per chat it stores token counts, model and provider name, and which notice has fired. No message content. Entries older than 30 days are removed.

Try it

MIT licensed and free. If you have very large context windows (1M tokens), lower thresholds like 0.50 and 0.80 give earlier nudges. Feedback and issues are welcome on GitHub.

I build more plugins and skills for Hermes at madebybrain.com/hermes-plugins.