You need to send the same investor update two ways — formal for the board deck, casual for the team Slack. Two windows, two copy-pastes, two prompts. What if you ran both in one function call?
Two agents with different system prompts? One formal rewrite, one casual. Run both on the same text, return both.
Exactly. Two agent instances, two independent calls, one dict back:
formal_agent = Agent(model, system_prompt="Rewrite formally.")
casual_agent = Agent(model, system_prompt="Rewrite casually.")
formal = formal_agent.run_sync(text).output
casual = casual_agent.run_sync(text).output
return {"formal": formal, "casual": casual}Are these two separate model calls? Does that mean twice the cost?
Two calls, yes. Each agent call is independent. The cost is low because the text is short — you're not doubling a large document, you're doubling a short update. Here's the full function:
def compare_tones(text: str) -> dict:
formal_agent = Agent(model, system_prompt="Rewrite formally.")
casual_agent = Agent(model, system_prompt="Rewrite casually.")
formal = formal_agent.run_sync(text).output
casual = casual_agent.run_sync(text).output
print(f"Formal: {formal[:40]}...")
return {"formal": formal, "casual": casual}I'm managing two AI employees with different writing styles. One in a suit, one in a hoodie.
Two personas, one function, one dict. You can extend this to three or four tones — add a technical agent for your engineering blog, a sales agent for the pitch deck version.
I write one update, run this function, and have both the board version and the team version ready. That's an hour back every week.
The dict is a natural unit for multi-output results — {"formal": ..., "casual": ...}. In Week 4 the capstone returns a sorted list of dicts. The pattern of 'multiple results in a structured container' is consistent throughout.
formal_agent = Agent(model, system_prompt="Rewrite formally.")
casual_agent = Agent(model, system_prompt="Rewrite casually.")
return {
"formal": formal_agent.run_sync(text).output,
"casual": casual_agent.run_sync(text).output,
}Multiple agents, same input, different system prompts. Results collected into a dict with descriptive keys.
Add more tones by creating more agents and adding them to the return dict:
"technical" agent for engineering blogs"sales" agent for pitch deck copy"brief" agent for push notification textThe calling code stays the same — one dict with more keys.
You need to send the same investor update two ways — formal for the board deck, casual for the team Slack. Two windows, two copy-pastes, two prompts. What if you ran both in one function call?
Two agents with different system prompts? One formal rewrite, one casual. Run both on the same text, return both.
Exactly. Two agent instances, two independent calls, one dict back:
formal_agent = Agent(model, system_prompt="Rewrite formally.")
casual_agent = Agent(model, system_prompt="Rewrite casually.")
formal = formal_agent.run_sync(text).output
casual = casual_agent.run_sync(text).output
return {"formal": formal, "casual": casual}Are these two separate model calls? Does that mean twice the cost?
Two calls, yes. Each agent call is independent. The cost is low because the text is short — you're not doubling a large document, you're doubling a short update. Here's the full function:
def compare_tones(text: str) -> dict:
formal_agent = Agent(model, system_prompt="Rewrite formally.")
casual_agent = Agent(model, system_prompt="Rewrite casually.")
formal = formal_agent.run_sync(text).output
casual = casual_agent.run_sync(text).output
print(f"Formal: {formal[:40]}...")
return {"formal": formal, "casual": casual}I'm managing two AI employees with different writing styles. One in a suit, one in a hoodie.
Two personas, one function, one dict. You can extend this to three or four tones — add a technical agent for your engineering blog, a sales agent for the pitch deck version.
I write one update, run this function, and have both the board version and the team version ready. That's an hour back every week.
The dict is a natural unit for multi-output results — {"formal": ..., "casual": ...}. In Week 4 the capstone returns a sorted list of dicts. The pattern of 'multiple results in a structured container' is consistent throughout.
formal_agent = Agent(model, system_prompt="Rewrite formally.")
casual_agent = Agent(model, system_prompt="Rewrite casually.")
return {
"formal": formal_agent.run_sync(text).output,
"casual": casual_agent.run_sync(text).output,
}Multiple agents, same input, different system prompts. Results collected into a dict with descriptive keys.
Add more tones by creating more agents and adding them to the return dict:
"technical" agent for engineering blogs"sales" agent for pitch deck copy"brief" agent for push notification textThe calling code stays the same — one dict with more keys.
Create a free account to get started. Paid plans unlock all tracks.