Agent patterns

Plan-and-execute compression

Plan-and-Execute agents first create a plan, then execute each step. The full plan is included in every execution step. Compression keeps the relevant plan steps and execution results.

By Arjun Shah - Creator of SuperCompress - Updated 2026-07-03

How Plan-and-Execute wastes tokens

A plan might have 10 steps. Steps 1-3 are "research the topic," step 4 is "analyze findings," step 5 is "write summary." When executing step 5, the agent still sees all 10 plan steps and all 4 previous execution results. Only step 5 and execution results from steps 3-4 are relevant.

Implementation

from supercompress import Compressor
comp = Compressor()

def execute_step(plan, completed_steps, current_step):
    context = f"Plan: {plan}\nCompleted: {completed_steps}"
    result = comp.compress(context, f"Execute step: {current_step}")
    return llm.generate(result.compressed_text)

Frequently asked questions

Does compression affect plan adherence?

No. The compressed context still contains the relevant plan steps.

Should I re-compress at every step?

Yes. Re-compress before each execution step with the latest results.

Build with less context

Put compression in front of your next LLM call.

Use the hosted API or run SuperCompress locally. Keep the evidence, drop the token waste, and measure the savings before it reaches your model.

Get an API keyRead the guide