Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

autourgos-summarizer

Framework: Autourgos Python License: Apache 2.0 Author Contributor Contributor

Scratchpad compression middleware for Autourgos agents. Automatically summarizes long reasoning chains so your agent never runs out of token space — even on tasks with dozens of iterations.

from autourgos_summarizer import AutoSummarizeMiddleware
from autourgos_agent import Agent

summarizer = AutoSummarizeMiddleware(summarize_every=5, max_scratchpad_chars=15000)
agent = Agent(llm=my_llm, middleware=[summarizer])
result = agent.invoke("Research the latest breakthroughs in quantum computing")

Features

  • Two triggers: every N iterations (summarize_every) and/or a scratchpad size cap (max_scratchpad_chars)
  • Dedicated summarization LLM — use a cheap/fast model just for compression, independent of the main agent's model
  • Thread-safe — a lock prevents duplicate summarizations when parallel tool callbacks fire
  • Depends on autourgos-agent; works with any Autourgos agent exposing scratchpad/llm/current_query

Table of Contents


Why Use This?

LLM agents accumulate a scratchpad — a growing log of thoughts, tool calls, and observations. On long tasks this scratchpad can hit the LLM's context window limit and crash, slow down responses, or confuse the LLM with too much irrelevant history. AutoSummarizeMiddleware compresses the scratchpad in the background every N iterations (or when it exceeds a size limit), keeping only what matters.


Install

pip install autourgos-summarizer

Depends on autourgos-agent.


Quick Start

from autourgos_summarizer import AutoSummarizeMiddleware
from autourgos_agent import Agent

summarizer = AutoSummarizeMiddleware(
    summarize_every=5,          # compress every 5 iterations
    max_scratchpad_chars=15000, # also compress if scratchpad exceeds 15k chars
)

agent = Agent(llm=my_llm, middleware=[summarizer])
result = agent.invoke("Research the latest breakthroughs in quantum computing")
print(result)

With Agent(verbose=True), this middleware also narrates its own actions into the agent's trace:

[Summarizer] Compressed scratchpad (iteration 5, was 18342 chars).

How It Works

AutoSummarizeMiddleware hooks into on_iteration_start. Before each iteration it checks:

  1. Is this a multiple of summarize_every? (e.g. iteration 5, 10, 15…)
  2. Is the scratchpad longer than max_scratchpad_chars?

If either is true, it calls the LLM (middleware's own llm if set, otherwise agent.llm) with a compression prompt that distills the scratchpad into:

[Summary of steps 1-N]
Key findings: ...
Tool results: ...
Current status: ...

This summary replaces the full scratchpad before the next LLM call. Summarization runs synchronously (the agent loop is paused at this point), and a threading.Lock prevents duplicate summarizations when parallel tool callbacks fire.


Dedicated Summarization LLM

Pass a separate llm used only for compressing the scratchpad — great for keeping costs low with a cheaper/faster model just for this job.

from autourgos_summarizer import AutoSummarizeMiddleware
from autourgos_openaichat import OpenAIChatModel

main_llm  = OpenAIChatModel(model="gpt-4o")       # main agent
cheap_llm = OpenAIChatModel(model="gpt-4o-mini")  # summarizer only

summarizer = AutoSummarizeMiddleware(summarize_every=5, llm=cheap_llm)
agent = Agent(llm=main_llm, middleware=[summarizer])
result = agent.invoke("Research the latest breakthroughs in quantum computing")

If llm is not provided, it falls back to agent.llm automatically.


Parameters

Parameter Type Default Description
summarize_every int | None 5 Summarize every N iterations. None = disable iteration-based trigger.
max_scratchpad_chars int 15000 Also trigger if scratchpad exceeds this many characters.
llm any None LLM for summarization. Needs .invoke(prompt). Falls back to agent.llm if not set.

Requirements

  • Python 3.9+
  • Any Autourgos agent that exposes agent.scratchpad, agent.llm, and agent.current_query (requires autourgos-agent>=2.0.2)

License

Apache License 2.0, Copyright (c) 2026 Jitin Kumar Sengar

Metadata

Release files for autourgos-summarizer 3.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autourgos-summarizer 3.1.4
File Size Uploaded
autourgos_summarizer-3.1.4.tar.gz 20.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autourgos-summarizer 3.1.4
File Interpreter ABI Platform
autourgos_summarizer-3.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 35.8 kB

Release files / autourgos_summarizer-3.1.4.tar.gz

Download URL autourgos_summarizer-3.1.4.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d4787590ebd8f200f91f5560a412dfc041432a69048bad9e9e8e89a5f8a5d7cf
BLAKE2b-256 checksum
How to use checksums
d221bcad4baddc4bd3e2b99dfdc0f0140e0d38c368be520c1f0338622794158e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / autourgos_summarizer-3.1.4-py3-none-any.whl

Download URL autourgos_summarizer-3.1.4-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12694e8480f08b5dd9def5e044232626116383bb5b838cfb3c15e70861ea2172
BLAKE2b-256 checksum
How to use checksums
6786de89093b450d1cc8c51a62473548e48cebd392d9b5727a7673986a1b44c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page