You have summarize_text and classify_sentiment as separate functions. A client transcript arrives — you want a summary and a sentiment label from one call. How do you connect them?
Call summarize_text first, take its output, pass it to classify_sentiment? So the summary becomes the input to the classifier?
Exactly. The output of agent A is a plain Python string — you can pass it anywhere, including into agent B's prompt. That's a pipeline:
summary = summarize_text(text)
label = classify_sentiment(summary)But why classify the summary instead of the original text? Wouldn't classifying the full transcript be more accurate?
Sometimes. But classifying a noisy 60-minute transcript is harder than classifying a clean two-sentence summary. The summariser strips filler and highlights tone. The classifier then works on signal, not noise. That's the value of chaining: each agent does one thing well.
def summarize_then_classify(text: str) -> str:
summary = summarize_text(text)
label = classify_sentiment(summary)
return labelI'm chaining these like functions now. Transcript in, classification out — two agents, one result.
And you've just described every AI pipeline in production: a sequence of transforms, each one producing the input for the next. The agents don't know about each other — they just see text in and text out.
The chain is just Python. I can add a third step, a fourth — just keep calling functions.
That's the key insight this week. Chains aren't a framework feature — they're function composition. Agent A's .output goes into Agent B's run_sync(). You already know how to do that.
The output of any .run_sync() call is a Python string. You can pass it directly into the next .run_sync() call:
summary = summarize_text(text) # agent A
label = classify_sentiment(summary) # agent B receives agent A's outputSpecialised prompts outperform general ones. A summariser trained (via system prompt) to produce two clean sentences gives the classifier a cleaner signal than the raw transcript would. Each agent does one thing well.
You have summarize_text and classify_sentiment as separate functions. A client transcript arrives — you want a summary and a sentiment label from one call. How do you connect them?
Call summarize_text first, take its output, pass it to classify_sentiment? So the summary becomes the input to the classifier?
Exactly. The output of agent A is a plain Python string — you can pass it anywhere, including into agent B's prompt. That's a pipeline:
summary = summarize_text(text)
label = classify_sentiment(summary)But why classify the summary instead of the original text? Wouldn't classifying the full transcript be more accurate?
Sometimes. But classifying a noisy 60-minute transcript is harder than classifying a clean two-sentence summary. The summariser strips filler and highlights tone. The classifier then works on signal, not noise. That's the value of chaining: each agent does one thing well.
def summarize_then_classify(text: str) -> str:
summary = summarize_text(text)
label = classify_sentiment(summary)
return labelI'm chaining these like functions now. Transcript in, classification out — two agents, one result.
And you've just described every AI pipeline in production: a sequence of transforms, each one producing the input for the next. The agents don't know about each other — they just see text in and text out.
The chain is just Python. I can add a third step, a fourth — just keep calling functions.
That's the key insight this week. Chains aren't a framework feature — they're function composition. Agent A's .output goes into Agent B's run_sync(). You already know how to do that.
The output of any .run_sync() call is a Python string. You can pass it directly into the next .run_sync() call:
summary = summarize_text(text) # agent A
label = classify_sentiment(summary) # agent B receives agent A's outputSpecialised prompts outperform general ones. A summariser trained (via system prompt) to produce two clean sentences gives the classifier a cleaner signal than the raw transcript would. Each agent does one thing well.
Create a free account to get started. Paid plans unlock all tracks.