mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING] Renamed create_agent to as_agent (#3249)
* Renamed create_agent to as_agent * Override for as_agent * Added override
This commit is contained in:
committed by
GitHub
Unverified
parent
a151f10cc2
commit
5687e13221
@@ -147,7 +147,7 @@ async def pattern_1_single_agent_with_closure() -> None:
|
||||
client = OpenAIChatClient(model_id="gpt-4o-mini")
|
||||
|
||||
# Create agent with both tools and shared context via middleware
|
||||
communication_agent = client.create_agent(
|
||||
communication_agent = client.as_agent(
|
||||
name="communication_agent",
|
||||
instructions=(
|
||||
"You are a communication assistant that can send emails and notifications. "
|
||||
@@ -294,14 +294,14 @@ async def pattern_2_hierarchical_with_kwargs_propagation() -> None:
|
||||
client = OpenAIChatClient(model_id="gpt-4o-mini")
|
||||
|
||||
# Create specialized sub-agents
|
||||
email_agent = client.create_agent(
|
||||
email_agent = client.as_agent(
|
||||
name="email_agent",
|
||||
instructions="You send emails using the send_email_v2 tool.",
|
||||
tools=[send_email_v2],
|
||||
middleware=[email_kwargs_tracker],
|
||||
)
|
||||
|
||||
sms_agent = client.create_agent(
|
||||
sms_agent = client.as_agent(
|
||||
name="sms_agent",
|
||||
instructions="You send SMS messages using the send_sms tool.",
|
||||
tools=[send_sms],
|
||||
@@ -309,7 +309,7 @@ async def pattern_2_hierarchical_with_kwargs_propagation() -> None:
|
||||
)
|
||||
|
||||
# Create coordinator that delegates to sub-agents
|
||||
coordinator = client.create_agent(
|
||||
coordinator = client.as_agent(
|
||||
name="coordinator",
|
||||
instructions=(
|
||||
"You coordinate communication tasks. "
|
||||
@@ -396,7 +396,7 @@ async def pattern_3_hierarchical_with_middleware() -> None:
|
||||
client = OpenAIChatClient(model_id="gpt-4o-mini")
|
||||
|
||||
# Sub-agent with validation middleware
|
||||
protected_agent = client.create_agent(
|
||||
protected_agent = client.as_agent(
|
||||
name="protected_agent",
|
||||
instructions="You perform protected operations that require authentication.",
|
||||
tools=[protected_operation],
|
||||
@@ -404,7 +404,7 @@ async def pattern_3_hierarchical_with_middleware() -> None:
|
||||
)
|
||||
|
||||
# Coordinator delegates to protected agent
|
||||
coordinator = client.create_agent(
|
||||
coordinator = client.as_agent(
|
||||
name="coordinator",
|
||||
instructions="You coordinate protected operations. Delegate to protected_executor.",
|
||||
tools=[
|
||||
|
||||
Reference in New Issue
Block a user