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.1

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.1
File Size Uploaded
autourgos_summarizer-3.1.1.tar.gz 19.2 kB Details

Built distribution (wheel)

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

Total release size: 34.0 kB

Release files / autourgos_summarizer-3.1.1.tar.gz

Download URL autourgos_summarizer-3.1.1.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dd64777bdaccfb7bcd9291476d29b743f2151396765eb10f3c1444cdf8d3eb96
BLAKE2b-256 checksum
How to use checksums
03b81fad3587f5e5f1436f255262698f00fa769eda0c32d7f8c565ee77d6002c
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.1-py3-none-any.whl

Download URL autourgos_summarizer-3.1.1-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
296282d57f6526e354f484bf4a30e0926e86862c2febc67c7eb19a29ffb887db
BLAKE2b-256 checksum
How to use checksums
b4fe600e85cc0e19858ea7c2a1e48694fd161e20f2a63b80901dfb5ef4a06664
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