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.
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.
Try it yourself
Paste your long prompt into the playground, ask a question, and see what SuperCompress keeps and removes. Free, no signup needed.