Skip to content

Commit ce961ad

Browse files
chore: revert irrelevant docstring/comment changes from upgrade
Remove docstring, comment, and test rename changes that were not required by the agent-framework 1.1.1 / azure-ai-projects 2.1.0 upgrade. Keeps only functional API migration changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9c23281 commit ce961ad

16 files changed

Lines changed: 93 additions & 100 deletions

File tree

src/ContentProcessor/src/libs/agent_framework/agent_builder.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4-
"""Fluent builder API for constructing Agent Framework Agent instances.
4+
"""Fluent builder API for constructing Agent Framework ChatAgent instances.
55
66
Provides a chainable ``AgentBuilder`` class and static factory methods
77
for creating pre-configured agents used by the map handler to invoke
@@ -29,7 +29,7 @@
2929

3030

3131
class AgentBuilder:
32-
"""Fluent builder for creating Agent instances with a chainable API.
32+
"""Fluent builder for creating ChatAgent instances with a chainable API.
3333
3434
This class provides two ways to create agents:
3535
1. Fluent API with method chaining (recommended for readability)
@@ -225,7 +225,7 @@ def with_middleware(
225225
"""Set middleware for request/response processing.
226226
227227
Args:
228-
middleware: Agent or chat middleware, or a list of them
228+
middleware: Middleware or list of middlewares
229229
230230
Returns:
231231
Self for method chaining
@@ -430,10 +430,10 @@ def with_kwargs(self, **kwargs: Any) -> "AgentBuilder":
430430
return self
431431

432432
def build(self) -> Agent:
433-
"""Build and return the configured Agent.
433+
"""Build and return the configured ChatAgent.
434434
435435
Returns:
436-
Agent: Configured agent instance ready for use
436+
ChatAgent: Configured agent instance ready for use
437437
438438
Example:
439439
.. code-block:: python
@@ -449,7 +449,6 @@ def build(self) -> Agent:
449449
async with agent:
450450
response = await agent.run("Hello!")
451451
"""
452-
# Build default_options from model parameters
453452
options: dict[str, Any] = {}
454453
if self._frequency_penalty is not None:
455454
options["frequency_penalty"] = self._frequency_penalty
@@ -539,7 +538,7 @@ def create_agent_by_agentinfo(
539538
"""Create an agent using AgentInfo configuration with full parameter support.
540539
541540
This method creates a chat client from the service configuration and then
542-
creates an Agent with the specified parameters. Agent name, description,
541+
creates a ChatAgent with the specified parameters. Agent name, description,
543542
and instructions are taken from AgentInfo but can be overridden via kwargs.
544543
545544
Args:
@@ -549,7 +548,7 @@ def create_agent_by_agentinfo(
549548
chat_message_store_factory: Factory function to create message stores
550549
conversation_id: ID for conversation tracking
551550
context_providers: Providers for additional context in conversations
552-
middleware: Agent or chat middleware for request/response processing
551+
middleware: Middleware for request/response processing
553552
frequency_penalty: Penalize frequent token usage (-2.0 to 2.0)
554553
logit_bias: Modify likelihood of specific tokens
555554
max_tokens: Maximum tokens in the response
@@ -562,14 +561,14 @@ def create_agent_by_agentinfo(
562561
store: Whether to store conversation history
563562
temperature: Sampling temperature (0.0 to 2.0)
564563
tool_choice: Tool selection mode
565-
tools: Tools available to the agent (MCP tools, callables, or generic tool objects)
564+
tools: Tools available to the agent (MCP tools, callables, or tool protocols)
566565
top_p: Nucleus sampling parameter
567566
user: User identifier for tracking
568567
additional_chat_options: Provider-specific options
569568
**kwargs: Additional keyword arguments
570569
571570
Returns:
572-
Agent: Configured agent instance ready for use
571+
ChatAgent: Configured agent instance ready for use
573572
574573
Example:
575574
.. code-block:: python
@@ -674,9 +673,9 @@ def create_agent(
674673
additional_chat_options: dict[str, Any] | None = None,
675674
**kwargs: Any,
676675
) -> Agent:
677-
"""Create a chat client agent.
676+
"""Create a Chat Client Agent.
678677
679-
Factory method that creates an Agent instance with the specified configuration.
678+
Factory method that creates a ChatAgent instance with the specified configuration.
680679
The agent uses a chat client to interact with language models and supports tools
681680
(MCP tools, callable functions), context providers, middleware, and both streaming
682681
and non-streaming responses.
@@ -690,7 +689,7 @@ def create_agent(
690689
chat_message_store_factory: Factory function to create message stores
691690
conversation_id: ID for conversation tracking
692691
context_providers: Providers for additional context in conversations
693-
middleware: Agent or chat middleware for request/response processing
692+
middleware: Middleware for request/response processing
694693
frequency_penalty: Penalize frequent token usage (-2.0 to 2.0)
695694
logit_bias: Modify likelihood of specific tokens
696695
max_tokens: Maximum tokens in the response
@@ -703,14 +702,14 @@ def create_agent(
703702
store: Whether to store conversation history
704703
temperature: Sampling temperature (0.0 to 2.0)
705704
tool_choice: Tool selection mode ("auto", "required", "none", or specific tool)
706-
tools: Tools available to the agent (MCP tools, callables, or generic tool objects)
705+
tools: Tools available to the agent (MCP tools, callables, or tool protocols)
707706
top_p: Nucleus sampling parameter
708707
user: User identifier for tracking
709708
additional_chat_options: Provider-specific options
710709
**kwargs: Additional keyword arguments
711710
712711
Returns:
713-
Agent: Configured chat agent instance that can be used directly or with async context manager
712+
ChatAgent: Configured chat agent instance that can be used directly or with async context manager
714713
715714
Examples:
716715
Non-streaming example (from azure_response_client_basic.py):
@@ -785,10 +784,9 @@ def create_agent(
785784
786785
Note:
787786
When the agent has MCP tools or needs proper resource cleanup, use it with
788-
``async with`` to ensure proper initialization and cleanup via the Agent's
787+
``async with`` to ensure proper initialization and cleanup via the ChatAgent's
789788
async context manager protocol.
790789
"""
791-
# Build default_options from model parameters
792790
options: dict[str, Any] = {}
793791
if frequency_penalty is not None:
794792
options["frequency_penalty"] = frequency_penalty

src/ContentProcessor/src/libs/agent_framework/agent_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""Declarative agent metadata with Jinja2 template rendering.
55
66
Used to define agent configuration (name, prompts, tools, type) that
7-
can be rendered with runtime context before constructing an Agent.
7+
can be rendered with runtime context before constructing a ChatAgent.
88
"""
99

1010
from typing import Any, Callable, MutableMapping, Sequence

src/ContentProcessorWorkflow/src/libs/agent_framework/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Modules
1010
-------
1111
agent_builder
12-
Fluent builder and static factories for creating ``Agent`` instances with
12+
Fluent builder and static factories for creating ``ChatAgent`` instances with
1313
chainable configuration (tools, temperature, middleware, etc.).
1414
agent_framework_helper
1515
Client factory that initializes and caches Azure OpenAI / Response / Assistant /

src/ContentProcessorWorkflow/src/libs/agent_framework/agent_builder.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4-
"""Fluent builder and static factories for Agent construction.
4+
"""Fluent builder and static factories for ChatAgent construction.
55
66
This module provides ``AgentBuilder``, a single class offering two complementary
7-
APIs for creating ``Agent`` instances:
7+
APIs for creating ``ChatAgent`` instances:
88
99
1. **Fluent builder** (recommended for readability):
1010
``AgentBuilder(client).with_name(...).with_tools(...).build()``
@@ -15,7 +15,7 @@
1515
1616
Design decisions:
1717
- Every ``with_*()`` setter returns ``self`` for method chaining.
18-
- ``build()`` and the static factories all delegate to the ``Agent``
18+
- ``build()`` and the static factories all delegate to the ``ChatAgent``
1919
constructor; the builder simply accumulates keyword arguments.
2020
- ``create_agent_by_agentinfo`` resolves the chat client from the
2121
``AgentFrameworkHelper`` attached to the ``AgentInfo``, so callers
@@ -24,7 +24,7 @@
2424
Supported configuration axes:
2525
- Model parameters: temperature, top_p, max_tokens, frequency/presence penalty.
2626
- Structured output: ``response_format`` (Pydantic model).
27-
- Tool binding: ``tools`` (MCP tools, callables, generic tool objects, dicts).
27+
- Tool binding: ``tools`` (MCP tools, callables, tool protocols, dicts).
2828
- Middleware: ``middleware`` (AgentMiddleware, ChatMiddleware, etc.).
2929
- Context providers: ``context_providers`` for injecting dynamic context.
3030
- Provider-specific options: ``additional_chat_options`` dict.
@@ -50,7 +50,7 @@
5050

5151

5252
class AgentBuilder:
53-
"""Fluent builder for creating Agent instances with a chainable API.
53+
"""Fluent builder for creating ChatAgent instances with a chainable API.
5454
5555
This class provides two ways to create agents:
5656
1. Fluent API with method chaining (recommended for readability)
@@ -90,7 +90,7 @@ def __init__(self, chat_client: SupportsChatGetResponse):
9090
"""Initialize the builder with a chat client and default-None fields.
9191
9292
All configuration is stored as private attributes. None of them are
93-
set to non-trivial defaults here; the ``Agent`` constructor applies
93+
set to non-trivial defaults here; the ``ChatAgent`` constructor applies
9494
its own defaults for any parameter that remains ``None``.
9595
9696
Args:
@@ -251,7 +251,7 @@ def with_middleware(
251251
"""Set middleware for request/response processing.
252252
253253
Args:
254-
middleware: Agent or chat middleware, or a list of them
254+
middleware: Middleware or list of middlewares
255255
256256
Returns:
257257
Self for method chaining
@@ -457,18 +457,18 @@ def with_kwargs(self, **kwargs: Any) -> "AgentBuilder":
457457
return self
458458

459459
def build(self) -> Agent:
460-
"""Construct an ``Agent`` from the accumulated configuration.
460+
"""Construct a ``ChatAgent`` from the accumulated configuration.
461461
462462
Processing steps:
463463
1. Collect every attribute set via ``with_*()`` calls.
464-
2. Pass them as keyword arguments to ``Agent(...)``.
464+
2. Pass them as keyword arguments to ``ChatAgent(...)``.
465465
3. Return the fully constructed agent.
466466
467467
The returned agent can be used directly or as an async context manager
468468
(``async with agent: ...``) when tools require lifecycle management.
469469
470470
Returns:
471-
An ``Agent`` instance ready for ``run()`` / ``run_stream()``.
471+
A ``ChatAgent`` instance ready for ``run()`` / ``run_stream()``.
472472
473473
Example:
474474
.. code-block:: python
@@ -484,7 +484,6 @@ def build(self) -> Agent:
484484
async with agent:
485485
response = await agent.run("Hello!")
486486
"""
487-
# Build default_options from model parameters
488487
options: dict[str, Any] = {}
489488
if self._frequency_penalty is not None:
490489
options["frequency_penalty"] = self._frequency_penalty
@@ -571,7 +570,7 @@ def create_agent_by_agentinfo(
571570
additional_chat_options: dict[str, Any] | None = None,
572571
**kwargs: Any,
573572
) -> Agent:
574-
"""Create an ``Agent`` from an ``AgentInfo`` metadata bundle.
573+
"""Create a ``ChatAgent`` from an ``AgentInfo`` metadata bundle.
575574
576575
This factory resolves the chat client automatically by reading the
577576
``AgentFrameworkHelper`` and ``ServiceConfig`` attached to the given
@@ -595,7 +594,7 @@ def create_agent_by_agentinfo(
595594
chat_message_store_factory: Factory function to create message stores
596595
conversation_id: ID for conversation tracking
597596
context_providers: Providers for additional context in conversations
598-
middleware: Agent or chat middleware for request/response processing
597+
middleware: Middleware for request/response processing
599598
frequency_penalty: Penalize frequent token usage (-2.0 to 2.0)
600599
logit_bias: Modify likelihood of specific tokens
601600
max_tokens: Maximum tokens in the response
@@ -608,14 +607,14 @@ def create_agent_by_agentinfo(
608607
store: Whether to store conversation history
609608
temperature: Sampling temperature (0.0 to 2.0)
610609
tool_choice: Tool selection mode
611-
tools: Tools available to the agent (MCP tools, callables, or generic tool objects)
610+
tools: Tools available to the agent (MCP tools, callables, or tool protocols)
612611
top_p: Nucleus sampling parameter
613612
user: User identifier for tracking
614613
additional_chat_options: Provider-specific options
615614
**kwargs: Additional keyword arguments
616615
617616
Returns:
618-
Agent: Configured agent instance ready for use
617+
ChatAgent: Configured agent instance ready for use
619618
620619
Example:
621620
.. code-block:: python
@@ -722,9 +721,9 @@ def create_agent(
722721
additional_chat_options: dict[str, Any] | None = None,
723722
**kwargs: Any,
724723
) -> Agent:
725-
"""Create a chat client agent.
724+
"""Create a Chat Client Agent.
726725
727-
Factory method that creates an Agent instance with the specified configuration.
726+
Factory method that creates a ChatAgent instance with the specified configuration.
728727
The agent uses a chat client to interact with language models and supports tools
729728
(MCP tools, callable functions), context providers, middleware, and both streaming
730729
and non-streaming responses.
@@ -738,7 +737,7 @@ def create_agent(
738737
chat_message_store_factory: Factory function to create message stores
739738
conversation_id: ID for conversation tracking
740739
context_providers: Providers for additional context in conversations
741-
middleware: Agent or chat middleware for request/response processing
740+
middleware: Middleware for request/response processing
742741
frequency_penalty: Penalize frequent token usage (-2.0 to 2.0)
743742
logit_bias: Modify likelihood of specific tokens
744743
max_tokens: Maximum tokens in the response
@@ -751,14 +750,14 @@ def create_agent(
751750
store: Whether to store conversation history
752751
temperature: Sampling temperature (0.0 to 2.0)
753752
tool_choice: Tool selection mode ("auto", "required", "none", or specific tool)
754-
tools: Tools available to the agent (MCP tools, callables, or generic tool objects)
753+
tools: Tools available to the agent (MCP tools, callables, or tool protocols)
755754
top_p: Nucleus sampling parameter
756755
user: User identifier for tracking
757756
additional_chat_options: Provider-specific options
758757
**kwargs: Additional keyword arguments
759758
760759
Returns:
761-
Agent: Configured chat agent instance that can be used directly or with async context manager
760+
ChatAgent: Configured chat agent instance that can be used directly or with async context manager
762761
763762
Examples:
764763
Non-streaming example (from azure_response_client_basic.py):
@@ -833,10 +832,9 @@ def create_agent(
833832
834833
Note:
835834
When the agent has MCP tools or needs proper resource cleanup, use it with
836-
``async with`` to ensure proper initialization and cleanup via the Agent's
835+
``async with`` to ensure proper initialization and cleanup via the ChatAgent's
837836
async context manager protocol.
838837
"""
839-
# Build default_options from model parameters
840838
options: dict[str, Any] = {}
841839
if frequency_penalty is not None:
842840
options["frequency_penalty"] = frequency_penalty

src/ContentProcessorWorkflow/src/libs/agent_framework/agent_info.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""Agent metadata container with Jinja2 template rendering.
55
66
This module defines ``AgentInfo``, a Pydantic model that bundles the configuration
7-
needed to instantiate an ``Agent`` via ``AgentBuilder.create_agent_by_agentinfo``:
7+
needed to instantiate a ``ChatAgent`` via ``AgentBuilder.create_agent_by_agentinfo``:
88
99
- **Identity** — agent name, description, and ``ClientType`` selector.
1010
- **Prompts** — a system prompt *or* an instruction string, either of which may
@@ -29,7 +29,7 @@
2929

3030

3131
class AgentInfo(BaseModel):
32-
"""Immutable metadata bundle for a single Agent.
32+
"""Immutable metadata bundle for a single ChatAgent.
3333
3434
Fields
3535
------
@@ -46,7 +46,7 @@ class AgentInfo(BaseModel):
4646
when both are set). Supports Jinja2 templates.
4747
agent_framework_helper : AgentFrameworkHelper | None
4848
Reference to the shared helper that owns client settings and cached clients.
49-
tools : Any | Callable | Sequence | None
49+
tools : ToolProtocol | Callable | Sequence | None
5050
Tools to bind to the agent (MCP tools, plain callables, or tool dicts).
5151
"""
5252

src/ContentProcessorWorkflow/src/libs/agent_framework/agent_speaking_capture.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ async def async_callback(capture_data: dict):
6868
# Without callback (store only)
6969
capture_middleware = AgentSpeakingCaptureMiddleware()
7070
71-
agent = Agent(
72-
client=client,
71+
agent = client.create_agent(
7372
name="MyAgent",
7473
middleware=[capture_middleware],
7574
...

0 commit comments

Comments
 (0)