Python: [BREAKING] Simplify API: ChatAgent -> Agent, ChatMessage -> Message (#3747)

* [BREAKING] Rename ChatAgent -> Agent, ChatMessage -> Message, ChatClientProtocol -> SupportsChatGetResponse

Simplify the public API by removing redundant 'Chat' prefix from core types:
- ChatAgent -> Agent
- RawChatAgent -> RawAgent
- ChatMessage -> Message
- ChatClientProtocol -> SupportsChatGetResponse

Also renamed internal WorkflowMessage (was Message in _runner_context) to avoid collision.

No backward compatibility aliases - this is a clean breaking change.

* [BREAKING] Rename Agent chat_client parameter to client

* Fix rebase issues: WorkflowMessage references and broken markdown links

* Fix formatting and lint issues from code quality checks

* Fix import ordering in workflow sample files

* fixed rebase

* Fix test failures: use WorkflowMessage and A2AMessage after ChatMessage→Message rename

- Replace Message(data=..., source_id=...) with WorkflowMessage(...) in workflow tests
- Fix isinstance check in A2A agent to use A2AMessage instead of Message
- Fix import in test_workflow_observability.py (Message→WorkflowMessage)

* Fix lint, fmt, and sample errors after ChatMessage→Message rename

- Auto-fix 70+ ruff lint issues across samples (ChatMessage→Message refs)
- Fix HostedVectorStoreContent→Content.from_hosted_vector_store in file search sample
- Fix _normalize_messages→normalize_messages in custom agent sample
- Fix context.terminate→raise MiddlewareTermination in middleware samples
- Fix with_update_hook→with_transform_hook in override middleware sample
- Add TOptions_co import back to custom_chat_client sample
- Add noqa for FastAPI File() default in chatkit sample
- Fix B023 loop variable capture in weather agent sample

* fix: update Agent constructor calls from chat_client to client in declaration-only tool tests

* fix: add register_cleanup to devui lazy-loading proxy and type stub

* fixed tests and updated new pieces

* fix agui typevar

* fix merge errors

* fix merge conflicts

* fiux merge

* Remove unused links

---------

Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
This commit is contained in:
Eduard van Valkenburg
2026-02-11 00:04:32 +01:00
committed by GitHub
Unverified
parent a4c9e43afb
commit 0521f5bed8
418 changed files with 5385 additions and 5389 deletions
@@ -164,43 +164,43 @@ async def main() -> None:
plugin = TicketingPlugin()
# Create Azure OpenAI client
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Create agents with structured outputs
self_service_agent = chat_client.as_agent(
self_service_agent = client.as_agent(
name="SelfServiceAgent",
instructions=SELF_SERVICE_INSTRUCTIONS,
default_options={"response_format": SelfServiceResponse},
)
ticketing_agent = chat_client.as_agent(
ticketing_agent = client.as_agent(
name="TicketingAgent",
instructions=TICKETING_INSTRUCTIONS,
tools=plugin.get_functions(),
default_options={"response_format": TicketingResponse},
)
routing_agent = chat_client.as_agent(
routing_agent = client.as_agent(
name="TicketRoutingAgent",
instructions=TICKET_ROUTING_INSTRUCTIONS,
tools=[plugin.get_ticket],
default_options={"response_format": RoutingResponse},
)
windows_support_agent = chat_client.as_agent(
windows_support_agent = client.as_agent(
name="WindowsSupportAgent",
instructions=WINDOWS_SUPPORT_INSTRUCTIONS,
tools=[plugin.get_ticket],
default_options={"response_format": SupportResponse},
)
resolution_agent = chat_client.as_agent(
resolution_agent = client.as_agent(
name="TicketResolutionAgent",
instructions=RESOLUTION_INSTRUCTIONS,
tools=[plugin.resolve_ticket],
)
escalation_agent = chat_client.as_agent(
escalation_agent = client.as_agent(
name="TicketEscalationAgent",
instructions=ESCALATION_INSTRUCTIONS,
tools=[plugin.get_ticket, plugin.send_notification],
@@ -122,41 +122,41 @@ class ManagerResponse(BaseModel):
async def main() -> None:
"""Run the deep research workflow."""
# Create Azure OpenAI client
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Create agents
research_agent = chat_client.as_agent(
research_agent = client.as_agent(
name="ResearchAgent",
instructions=RESEARCH_INSTRUCTIONS,
)
planner_agent = chat_client.as_agent(
planner_agent = client.as_agent(
name="PlannerAgent",
instructions=PLANNER_INSTRUCTIONS,
)
manager_agent = chat_client.as_agent(
manager_agent = client.as_agent(
name="ManagerAgent",
instructions=MANAGER_INSTRUCTIONS,
default_options={"response_format": ManagerResponse},
)
summary_agent = chat_client.as_agent(
summary_agent = client.as_agent(
name="SummaryAgent",
instructions=SUMMARY_INSTRUCTIONS,
)
knowledge_agent = chat_client.as_agent(
knowledge_agent = client.as_agent(
name="KnowledgeAgent",
instructions=KNOWLEDGE_INSTRUCTIONS,
)
coder_agent = chat_client.as_agent(
coder_agent = client.as_agent(
name="CoderAgent",
instructions=CODER_INSTRUCTIONS,
)
weather_agent = chat_client.as_agent(
weather_agent = client.as_agent(
name="WeatherAgent",
instructions=WEATHER_INSTRUCTIONS,
)
@@ -72,8 +72,8 @@ Session Complete
```python
# Create the agent with tools
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
menu_agent = chat_client.as_agent(
client = AzureOpenAIChatClient(credential=AzureCliCredential())
menu_agent = client.as_agent(
name="MenuAgent",
instructions="You are a helpful restaurant menu assistant...",
tools=[get_menu, get_specials, get_item_price],
@@ -62,8 +62,8 @@ def get_item_price(name: Annotated[str, Field(description="Menu item name")]) ->
async def main():
# Create agent with tools
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
menu_agent = chat_client.as_agent(
client = AzureOpenAIChatClient(credential=AzureCliCredential())
menu_agent = client.as_agent(
name="MenuAgent",
instructions="Answer questions about menu items, specials, and prices.",
tools=[get_menu, get_specials, get_item_price],
@@ -49,17 +49,17 @@ Return the final polished version."""
async def main() -> None:
"""Run the marketing workflow with real Azure AI agents."""
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
client = AzureOpenAIChatClient(credential=AzureCliCredential())
analyst_agent = chat_client.as_agent(
analyst_agent = client.as_agent(
name="AnalystAgent",
instructions=ANALYST_INSTRUCTIONS,
)
writer_agent = chat_client.as_agent(
writer_agent = client.as_agent(
name="WriterAgent",
instructions=WRITER_INSTRUCTIONS,
)
editor_agent = chat_client.as_agent(
editor_agent = client.as_agent(
name="EditorAgent",
instructions=EDITOR_INSTRUCTIONS,
)
@@ -51,15 +51,15 @@ Focus on building understanding, not just getting the right answer."""
async def main() -> None:
"""Run the student-teacher workflow with real Azure AI agents."""
# Create chat client
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Create student and teacher agents
student_agent = chat_client.as_agent(
student_agent = client.as_agent(
name="StudentAgent",
instructions=STUDENT_INSTRUCTIONS,
)
teacher_agent = chat_client.as_agent(
teacher_agent = client.as_agent(
name="TeacherAgent",
instructions=TEACHER_INSTRUCTIONS,
)