Skip to content
PentAGI
Concepts

Context management

How PentAGI keeps long flows within the model's context window by summarizing older parts of each agent's chain, and the settings that tune it.

Long flows produce more conversation than any model can hold. PentAGI keeps each agent's chain within bounds with chain summarization: after every agent turn, older sections are condensed while the most recent ones stay in full unless they outgrow their size limits. If PentAGI knows the model's context window — from its built-in model catalogs, or from a custom endpoint whose model list reports it — and the chain still does not fit, it is compacted once more right before the model call. Ollama models and others with an unknown window get no such step, so lower the sizes below for a model with a small context.

Chain summarization steps after each agent turn and before each model call

Yes

No

Agent turn finished

Condense each older section into one summary

Keep the recent sections within their size limits

Summarize old question-answer pairs

Next model call: fits the context window?

Send the chain

Compact to the window size

Tuning

The defaults suit most models. Agents and the interactive assistant have separate settings; the assistant keeps more recent history.

SettingAgentsAssistant
Cap the recent sectionsSUMMARIZER_PRESERVE_LAST=trueASSISTANT_SUMMARIZER_PRESERVE_LAST=true
Recent section size limitSUMMARIZER_LAST_SEC_BYTES=51200ASSISTANT_SUMMARIZER_LAST_SEC_BYTES=76800
Largest single tool resultSUMMARIZER_MAX_BP_BYTES=16384ASSISTANT_SUMMARIZER_MAX_BP_BYTES=16384
Question-answer sections keptSUMMARIZER_MAX_QA_SECTIONS=10ASSISTANT_SUMMARIZER_MAX_QA_SECTIONS=7
Size of those sectionsSUMMARIZER_MAX_QA_BYTES=65536ASSISTANT_SUMMARIZER_MAX_QA_BYTES=76800
Recent sections not condensedSUMMARIZER_KEEP_QA_SECTIONS=1ASSISTANT_SUMMARIZER_KEEP_QA_SECTIONS=3

With false, the recent sections have no size limit of their own, and the single tool result limit does not apply either.

SUMMARIZER_USE_QA enables the question-answer strategy (on by default) and SUMMARIZER_SUM_MSG_HUMAN_IN_QA also summarizes your own messages inside it (off by default). Both apply to agents only: the assistant always uses the strategy and never summarizes your messages.

Last updated on