You have a summarizer agent from Week 1 and a Literal-typed classifier from Day 11. What happens if you run them in series?
The summarizer condenses the ticket, the classifier reads the summary instead of the full text — and now the classifier output is validated to be exactly high, medium, or low?
Exactly the combination. The wiring is the same Python variable pattern, but the second agent uses result_type=Literal instead of a normalized string. That gives you both noise reduction and a validated output in one function:
summary = summarize_agent.run_sync(text).output
urgency = urgency_agent.run_sync(summary).output # guaranteed one of 3 valuesWhy summarize before classifying? Why not classify the full ticket directly?
Classification accuracy drops on noisy input. A five-paragraph complaint has timestamps, repetition, pleasantries. The summarizer strips the noise so the classifier sees a clean one-sentence version. Both agents do less work and the result is more reliable:
from typing import Literal
def summarize_and_classify(text: str) -> str:
summarize_agent = Agent(model, system_prompt="Summarize the following support ticket in 1-2 sentences.")
summary = summarize_agent.run_sync(text).output
urgency_agent = Agent(model, result_type=Literal["high", "medium", "low"])
return urgency_agent.run_sync(summary).outputThe urgency agent has no system_prompt at all? The Literal type is doing all the work?
The constraint already tells the model its allowed outputs. You can add a system prompt for extra guidance, but the type-level enforcement is usually enough — the model sees the summary and knows it must reply with one of the three exact strings. No .strip().lower() needed.
And I return the output directly because the Literal guarantees the shape — no defensive normalization anywhere?
Exactly. Type-level enforcement replaces runtime cleaning. Write summarize_and_classify(text) now — two agents, the summary flowing into the classifier, return the Literal-typed urgency.
TL;DR: summarizer reduces noise, Literal classifier validates the label.
summarize_agent — system_prompt compresses to 1-2 sentencesurgency_agent — result_type=Literal["high","medium","low"] enforces the label| One big call | Summarize → Classify | |
|---|---|---|
| Input tokens for classifier | Full ticket | 1-2 sentences |
| Classification accuracy | Lower | Higher |
| Output normalization | .strip().lower() | Not needed |
Each call is stateless — the agents do not share memory.
You have a summarizer agent from Week 1 and a Literal-typed classifier from Day 11. What happens if you run them in series?
The summarizer condenses the ticket, the classifier reads the summary instead of the full text — and now the classifier output is validated to be exactly high, medium, or low?
Exactly the combination. The wiring is the same Python variable pattern, but the second agent uses result_type=Literal instead of a normalized string. That gives you both noise reduction and a validated output in one function:
summary = summarize_agent.run_sync(text).output
urgency = urgency_agent.run_sync(summary).output # guaranteed one of 3 valuesWhy summarize before classifying? Why not classify the full ticket directly?
Classification accuracy drops on noisy input. A five-paragraph complaint has timestamps, repetition, pleasantries. The summarizer strips the noise so the classifier sees a clean one-sentence version. Both agents do less work and the result is more reliable:
from typing import Literal
def summarize_and_classify(text: str) -> str:
summarize_agent = Agent(model, system_prompt="Summarize the following support ticket in 1-2 sentences.")
summary = summarize_agent.run_sync(text).output
urgency_agent = Agent(model, result_type=Literal["high", "medium", "low"])
return urgency_agent.run_sync(summary).outputThe urgency agent has no system_prompt at all? The Literal type is doing all the work?
The constraint already tells the model its allowed outputs. You can add a system prompt for extra guidance, but the type-level enforcement is usually enough — the model sees the summary and knows it must reply with one of the three exact strings. No .strip().lower() needed.
And I return the output directly because the Literal guarantees the shape — no defensive normalization anywhere?
Exactly. Type-level enforcement replaces runtime cleaning. Write summarize_and_classify(text) now — two agents, the summary flowing into the classifier, return the Literal-typed urgency.
TL;DR: summarizer reduces noise, Literal classifier validates the label.
summarize_agent — system_prompt compresses to 1-2 sentencesurgency_agent — result_type=Literal["high","medium","low"] enforces the label| One big call | Summarize → Classify | |
|---|---|---|
| Input tokens for classifier | Full ticket | 1-2 sentences |
| Classification accuracy | Lower | Higher |
| Output normalization | .strip().lower() | Not needed |
Each call is stateless — the agents do not share memory.
Create a free account to get started. Paid plans unlock all tracks.