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:
Dmytro Struk
2026-01-16 11:21:52 -08:00
committed by GitHub
Unverified
parent a151f10cc2
commit 5687e13221
163 changed files with 498 additions and 358 deletions
@@ -77,12 +77,12 @@ def _print_semantic_kernel_outputs(outputs: Sequence[ChatMessageContent]) -> Non
async def run_agent_framework_example(prompt: str) -> Sequence[list[ChatMessage]]:
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
physics = chat_client.create_agent(
physics = chat_client.as_agent(
instructions=("You are an expert in physics. Answer questions from a physics perspective."),
name="physics",
)
chemistry = chat_client.create_agent(
chemistry = chat_client.as_agent(
instructions=("You are an expert in chemistry. Answer questions from a chemistry perspective."),
name="chemistry",
)
@@ -234,7 +234,7 @@ async def run_agent_framework_example(task: str) -> str:
workflow = (
GroupChatBuilder()
.set_manager(
manager=AzureOpenAIChatClient(credential=credential).create_agent(),
manager=AzureOpenAIChatClient(credential=credential).as_agent(),
display_name="Coordinator",
)
.participants(researcher=researcher, planner=planner)
@@ -180,7 +180,7 @@ async def run_semantic_kernel_example(initial_task: str, scripted_responses: Seq
def _create_af_agents(client: AzureOpenAIChatClient):
triage = client.create_agent(
triage = client.as_agent(
name="triage_agent",
instructions=(
"You are a customer support triage agent. Route requests:\n"
@@ -189,19 +189,19 @@ def _create_af_agents(client: AzureOpenAIChatClient):
"- handoff_to_order_return_agent for returns"
),
)
refund = client.create_agent(
refund = client.as_agent(
name="refund_agent",
instructions=(
"Handle refunds. Ask for order id and reason. If shipping info is needed, hand off to order_status_agent."
),
)
status = client.create_agent(
status = client.as_agent(
name="order_status_agent",
instructions=(
"Provide order status, tracking, and timelines. If billing questions appear, hand off to refund_agent."
),
)
returns = client.create_agent(
returns = client.as_agent(
name="order_return_agent",
instructions=(
"Coordinate returns, confirm addresses, and summarize next steps. Hand off to triage_agent if unsure."
@@ -63,12 +63,12 @@ async def sk_agent_response_callback(
async def run_agent_framework_example(prompt: str) -> list[ChatMessage]:
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
writer = chat_client.create_agent(
writer = chat_client.as_agent(
instructions=("You are a concise copywriter. Provide a single, punchy marketing sentence based on the prompt."),
name="writer",
)
reviewer = chat_client.create_agent(
reviewer = chat_client.as_agent(
instructions=("You are a thoughtful reviewer. Give brief feedback on the previous assistant message."),
name="reviewer",
)