Prevent multi-agent conversation history context blowup in CrewAI swarms.
Compress agent-to-agent task outputs and state memory in CrewAI multi-agent workflows.
Install LLMSlim and the official CrewAI SDK using your package manager:
pip install llmslim crewai1. Worker agent completes intermediate task and returns result.
2. LLMSlim prunes verbose output before appending to shared Crew state.
3. Manager agent receives token-dense task context.
Complete, runnable implementation wrapper for CrewAI:
from crewai import Agent, Task, Crew
from llmslim import compress
def slim_task_output_callback(output):
# Compress intermediate agent output before passing to downstream agents
raw_text = str(output.raw)
compressed_text = compress(raw_text, target_ratio=0.4).compressed_text
print(f"[LLMSlim] Compressed task output by 60%")
return compressed_text
researcher = Agent(
role="Market Analyst",
goal="Gather financial metrics",
backstory="Senior enterprise analyst",
verbose=True
)
task = Task(
description="Analyze 2026 enterprise software market trends.",
agent=researcher,
callback=slim_task_output_callback
)| Metric Dimension | Uncompressed Payload | LLMSlim Compressed | Recorded Impact |
|---|---|---|---|
| Inter-Agent State Volume | 12,000 tokens | 4,800 tokens | 60% Memory Reduction |
Yes. Task callbacks accept custom Python processing functions.