You want two versions of the same message — one professional, one casual — returned in one function call. How would you try it the hard way?
One agent and ask for both? Like "give me formal and casual" in the same prompt?
You can, but the model has to hold two personalities in one response. Cleaner: two agents, each with its own system_prompt. The prompt is the agent's personality — change it and the agent talks differently. Two agents, two calls, a plain Python dict with both outputs:
formal_agent = Agent(model, system_prompt="Rewrite the text in a formal, professional tone.")
casual_agent = Agent(model, system_prompt="Rewrite the text in a casual, friendly tone.")Same model, same call shape — the only difference is the system_prompt?
That is all that separates them. The infrastructure, the HTTP round-trip, the token flow — identical. The prompt decides whether the model acts as a business editor or a friendly copywriter. Two agents, two calls, no Pydantic needed because the caller already knows the keys:
def compare_tones(text: str) -> dict:
formal_agent = Agent(model, system_prompt="Rewrite the text in a formal, professional tone.")
casual_agent = Agent(model, system_prompt="Rewrite the text in a casual, friendly tone.")
return {
"formal": formal_agent.run_sync(text).output,
"casual": casual_agent.run_sync(text).output,
}Why a plain dict and not a Pydantic model for the return?
Pydantic earns its weight when the model decides the fields or the values need validation. Here you are the one assembling the dict from two variables — the keys are fixed by your code. A literal {} is simpler and cheaper.
And I could add a third tone — concise, hype, apologetic — just by registering another agent and another key?
Linear scaling. Three tones, ten tones, fifty tones — add an agent per role, add a key per tone, ship. Now write compare_tones(text): formal agent, casual agent, one dict out.
TL;DR: system_prompt is personality — spin up as many specialized agents as you need.
run_sync(text) twice| One agent, two jobs | Two specialized agents | |
|---|---|---|
| Style separation | Mixed | Clean |
| Each output | Constrained by other | Independent |
| Adding a third tone | Rewrite prompt | Add agent + key |
Pydantic is overkill when you already know the output keys at write time.
You want two versions of the same message — one professional, one casual — returned in one function call. How would you try it the hard way?
One agent and ask for both? Like "give me formal and casual" in the same prompt?
You can, but the model has to hold two personalities in one response. Cleaner: two agents, each with its own system_prompt. The prompt is the agent's personality — change it and the agent talks differently. Two agents, two calls, a plain Python dict with both outputs:
formal_agent = Agent(model, system_prompt="Rewrite the text in a formal, professional tone.")
casual_agent = Agent(model, system_prompt="Rewrite the text in a casual, friendly tone.")Same model, same call shape — the only difference is the system_prompt?
That is all that separates them. The infrastructure, the HTTP round-trip, the token flow — identical. The prompt decides whether the model acts as a business editor or a friendly copywriter. Two agents, two calls, no Pydantic needed because the caller already knows the keys:
def compare_tones(text: str) -> dict:
formal_agent = Agent(model, system_prompt="Rewrite the text in a formal, professional tone.")
casual_agent = Agent(model, system_prompt="Rewrite the text in a casual, friendly tone.")
return {
"formal": formal_agent.run_sync(text).output,
"casual": casual_agent.run_sync(text).output,
}Why a plain dict and not a Pydantic model for the return?
Pydantic earns its weight when the model decides the fields or the values need validation. Here you are the one assembling the dict from two variables — the keys are fixed by your code. A literal {} is simpler and cheaper.
And I could add a third tone — concise, hype, apologetic — just by registering another agent and another key?
Linear scaling. Three tones, ten tones, fifty tones — add an agent per role, add a key per tone, ship. Now write compare_tones(text): formal agent, casual agent, one dict out.
TL;DR: system_prompt is personality — spin up as many specialized agents as you need.
run_sync(text) twice| One agent, two jobs | Two specialized agents | |
|---|---|---|
| Style separation | Mixed | Clean |
| Each output | Constrained by other | Independent |
| Adding a third tone | Rewrite prompt | Add agent + key |
Pydantic is overkill when you already know the output keys at write time.
Create a free account to get started. Paid plans unlock all tracks.