The brief is now two pages long. Feeding all of it into two agents twice wastes tokens. What is the fix?
Compress once, use the compressed version as input to both agents? Same pattern as Day 13, but feeding into multiple agents instead of one?
Exactly. One summarizer call shrinks the brief; two specialist agents consume the compressed memory. Compression plus fan-out:
summarizer = Agent(model, system_prompt="Summarize the brief into a compact paragraph.")
memory = summarizer.run_sync(brief).output
events = events_agent.run_sync(memory).output
tasks = tasks_agent.run_sync(memory).outputSo compression happens once, memory flows into both specialists, and the outputs come back without ever seeing the raw two-page brief again?
The specialists only see the memory. Token spend drops, the brief stays clean, and the morning routine fits into one dict with the memory and both output lists:
def morning_orchestration(brief: str) -> dict:
summarizer = Agent(model, system_prompt="Summarize the brief into a compact paragraph.")
events_agent = Agent(model, result_type=list[str], system_prompt="Extract calendar events as short phrases.")
tasks_agent = Agent(model, result_type=list[str], system_prompt="Extract action items as short tasks.")
memory = summarizer.run_sync(brief).output
out = {
"memory": memory,
"events": events_agent.run_sync(memory).output,
"tasks": tasks_agent.run_sync(memory).output,
}
return outIs the memory really short enough to save tokens even after the extra summarizer call?
For briefs over 2 KB, yes — the summary is typically a tenth of the original. Two specialist calls on the compressed string cost less than two specialist calls on the raw brief. Compression pays for itself after the first fan-out.
So this is the Week 3 capstone — compression flowing into two agents, state shared through memory, one clean dict out?
Week 3 in one function. Compress, fan out, merge — the canonical shape of every memory-aware multi-agent routine.
TL;DR: summarize once; feed the short memory to every downstream agent.
| Shape | Token cost |
|---|---|
| Two agents on raw brief | high |
| Summarize + two agents on memory | low |
Compression amortizes — pays for itself after the second specialist call.
The brief is now two pages long. Feeding all of it into two agents twice wastes tokens. What is the fix?
Compress once, use the compressed version as input to both agents? Same pattern as Day 13, but feeding into multiple agents instead of one?
Exactly. One summarizer call shrinks the brief; two specialist agents consume the compressed memory. Compression plus fan-out:
summarizer = Agent(model, system_prompt="Summarize the brief into a compact paragraph.")
memory = summarizer.run_sync(brief).output
events = events_agent.run_sync(memory).output
tasks = tasks_agent.run_sync(memory).outputSo compression happens once, memory flows into both specialists, and the outputs come back without ever seeing the raw two-page brief again?
The specialists only see the memory. Token spend drops, the brief stays clean, and the morning routine fits into one dict with the memory and both output lists:
def morning_orchestration(brief: str) -> dict:
summarizer = Agent(model, system_prompt="Summarize the brief into a compact paragraph.")
events_agent = Agent(model, result_type=list[str], system_prompt="Extract calendar events as short phrases.")
tasks_agent = Agent(model, result_type=list[str], system_prompt="Extract action items as short tasks.")
memory = summarizer.run_sync(brief).output
out = {
"memory": memory,
"events": events_agent.run_sync(memory).output,
"tasks": tasks_agent.run_sync(memory).output,
}
return outIs the memory really short enough to save tokens even after the extra summarizer call?
For briefs over 2 KB, yes — the summary is typically a tenth of the original. Two specialist calls on the compressed string cost less than two specialist calls on the raw brief. Compression pays for itself after the first fan-out.
So this is the Week 3 capstone — compression flowing into two agents, state shared through memory, one clean dict out?
Week 3 in one function. Compress, fan out, merge — the canonical shape of every memory-aware multi-agent routine.
TL;DR: summarize once; feed the short memory to every downstream agent.
| Shape | Token cost |
|---|---|
| Two agents on raw brief | high |
| Summarize + two agents on memory | low |
Compression amortizes — pays for itself after the second specialist call.
Create a free account to get started. Paid plans unlock all tracks.