Skip to content

Commit bd814b3

Browse files
committed
Merge remote-tracking branch 'upstream/main' into peterj/updateautogen0425
* upstream/main: Update website for v0.5.5 (microsoft#6401) Document custom message types in teams API docs (microsoft#6400) [doc] Clarify selector prompt for SelectorGroupChat (microsoft#6399) Add functional termination condition (microsoft#6398) Update: implement return_value_as_string for McpToolAdapter (microsoft#6380) Update version to 0.5.5 (microsoft#6397) Add example using autogen-core and FastAPI for handoff multi-agent design pattern with streaming and UI (microsoft#6391) Update agent documentation (microsoft#6394) AssistantAgent to support Workbench (microsoft#6393) TEST: skip when macos+uv and adding uv venv tests (microsoft#6387) Add guide for workbench and mcp & bug fixes for create_mcp_server_session (microsoft#6392) Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
2 parents a8a8991 + 4eb256d commit bd814b3

44 files changed

Lines changed: 2154 additions & 411 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/1-bug_report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ body:
9090
multiple: false
9191
options:
9292
- "Python dev (main branch)"
93+
- "Python 0.5.5"
9394
- "Python 0.5.4"
9495
- "Python 0.5.3"
9596
- "Python 0.5.2"

.github/workflows/docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
[
3434
# For main use the workflow target
3535
{ ref: "${{github.ref}}", dest-dir: dev, uv-version: "0.5.13", sphinx-release-override: "dev" },
36-
{ ref: "python-v0.5.4", dest-dir: stable, uv-version: "0.5.13", sphinx-release-override: "stable" },
36+
{ ref: "python-v0.5.5", dest-dir: stable, uv-version: "0.5.13", sphinx-release-override: "stable" },
3737
{ ref: "v0.4.0.post1", dest-dir: "0.4.0", uv-version: "0.5.13", sphinx-release-override: "" },
3838
{ ref: "v0.4.1", dest-dir: "0.4.1", uv-version: "0.5.13", sphinx-release-override: "" },
3939
{ ref: "v0.4.2", dest-dir: "0.4.2", uv-version: "0.5.13", sphinx-release-override: "" },
@@ -48,6 +48,7 @@ jobs:
4848
{ ref: "python-v0.5.2", dest-dir: "0.5.2", uv-version: "0.5.13", sphinx-release-override: "" },
4949
{ ref: "python-v0.5.3", dest-dir: "0.5.3", uv-version: "0.5.13", sphinx-release-override: "" },
5050
{ ref: "python-v0.5.4", dest-dir: "0.5.4", uv-version: "0.5.13", sphinx-release-override: "" },
51+
{ ref: "python-v0.5.5", dest-dir: "0.5.5", uv-version: "0.5.13", sphinx-release-override: "" },
5152
]
5253
steps:
5354
- name: Checkout

docs/switcher.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
"url": "/autogen/dev/"
66
},
77
{
8-
"name": "0.5.4 (stable)",
8+
"name": "0.5.5 (stable)",
99
"version": "stable",
1010
"url": "/autogen/stable/",
1111
"preferred": true
1212
},
13+
{
14+
"name": "0.5.4",
15+
"version": "0.5.4",
16+
"url": "/autogen/0.5.4/"
17+
},
1318
{
1419
"name": "0.5.3",
1520
"version": "0.5.3",

python/packages/autogen-agentchat/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "autogen-agentchat"
7-
version = "0.5.4"
7+
version = "0.5.5"
88
license = {file = "LICENSE-CODE"}
99
description = "AutoGen agents and teams library"
1010
readme = "README.md"
@@ -15,7 +15,7 @@ classifiers = [
1515
"Operating System :: OS Independent",
1616
]
1717
dependencies = [
18-
"autogen-core==0.5.4",
18+
"autogen-core==0.5.5",
1919
]
2020

2121
[tool.ruff]

python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py

Lines changed: 144 additions & 103 deletions
Large diffs are not rendered by default.

python/packages/autogen-agentchat/src/autogen_agentchat/conditions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from ._terminations import (
77
ExternalTermination,
8+
FunctionalTermination,
89
FunctionCallTermination,
910
HandoffTermination,
1011
MaxMessageTermination,
@@ -27,4 +28,5 @@
2728
"SourceMatchTermination",
2829
"TextMessageTermination",
2930
"FunctionCallTermination",
31+
"FunctionalTermination",
3032
]

python/packages/autogen-agentchat/src/autogen_agentchat/conditions/_terminations.py

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import asyncio
12
import time
2-
from typing import List, Sequence
3+
from typing import Awaitable, Callable, List, Sequence
34

45
from autogen_core import Component
56
from pydantic import BaseModel
@@ -154,6 +155,77 @@ def _from_config(cls, config: TextMentionTerminationConfig) -> Self:
154155
return cls(text=config.text)
155156

156157

158+
class FunctionalTermination(TerminationCondition):
159+
"""Terminate the conversation if an functional expression is met.
160+
161+
Args:
162+
func (Callable[[Sequence[BaseAgentEvent | BaseChatMessage]], bool] | Callable[[Sequence[BaseAgentEvent | BaseChatMessage]], Awaitable[bool]]): A function that takes a sequence of messages
163+
and returns True if the termination condition is met, False otherwise.
164+
The function can be a callable or an async callable.
165+
166+
Example:
167+
168+
.. code-block:: python
169+
170+
import asyncio
171+
from typing import Sequence
172+
173+
from autogen_agentchat.conditions import FunctionalTermination
174+
from autogen_agentchat.messages import BaseAgentEvent, BaseChatMessage, StopMessage
175+
176+
177+
def expression(messages: Sequence[BaseAgentEvent | BaseChatMessage]) -> bool:
178+
# Check if the last message is a stop message
179+
return isinstance(messages[-1], StopMessage)
180+
181+
182+
termination = FunctionalTermination(expression)
183+
184+
185+
async def run() -> None:
186+
messages = [
187+
StopMessage(source="agent1", content="Stop"),
188+
]
189+
result = await termination(messages)
190+
print(result)
191+
192+
193+
asyncio.run(run())
194+
195+
.. code-block:: text
196+
197+
StopMessage(source="FunctionalTermination", content="Functional termination condition met")
198+
199+
"""
200+
201+
def __init__(
202+
self,
203+
func: Callable[[Sequence[BaseAgentEvent | BaseChatMessage]], bool]
204+
| Callable[[Sequence[BaseAgentEvent | BaseChatMessage]], Awaitable[bool]],
205+
) -> None:
206+
self._func = func
207+
self._terminated = False
208+
209+
@property
210+
def terminated(self) -> bool:
211+
return self._terminated
212+
213+
async def __call__(self, messages: Sequence[BaseAgentEvent | BaseChatMessage]) -> StopMessage | None:
214+
if self._terminated:
215+
raise TerminatedException("Termination condition has already been reached")
216+
if asyncio.iscoroutinefunction(self._func):
217+
result = await self._func(messages)
218+
else:
219+
result = self._func(messages)
220+
if result is True:
221+
self._terminated = True
222+
return StopMessage(content="Functional termination condition met", source="FunctionalTermination")
223+
return None
224+
225+
async def reset(self) -> None:
226+
self._terminated = False
227+
228+
157229
class TokenUsageTerminationConfig(BaseModel):
158230
max_total_token: int | None
159231
max_prompt_token: int | None

python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class MagenticOneGroupChat(BaseGroupChat, Component[MagenticOneGroupChatConfig])
4747
max_turns (int, optional): The maximum number of turns in the group chat before stopping. Defaults to 20.
4848
max_stalls (int, optional): The maximum number of stalls allowed before re-planning. Defaults to 3.
4949
final_answer_prompt (str, optional): The LLM prompt used to generate the final answer or response from the team's transcript. A default (sensible for GPT-4o class models) is provided.
50+
custom_message_types (List[type[BaseAgentEvent | BaseChatMessage]], optional): A list of custom message types that will be used in the group chat.
51+
If you are using custom message types or your agents produces custom message types, you need to specify them here.
52+
Make sure your custom message types are subclasses of :class:`~autogen_agentchat.messages.BaseAgentEvent` or :class:`~autogen_agentchat.messages.BaseChatMessage`.
5053
emit_team_events (bool, optional): Whether to emit team events through :meth:`BaseGroupChat.run_stream`. Defaults to False.
5154
5255
Raises:
@@ -105,6 +108,7 @@ def __init__(
105108
runtime: AgentRuntime | None = None,
106109
max_stalls: int = 3,
107110
final_answer_prompt: str = ORCHESTRATOR_FINAL_ANSWER_PROMPT,
111+
custom_message_types: List[type[BaseAgentEvent | BaseChatMessage]] | None = None,
108112
emit_team_events: bool = False,
109113
):
110114
super().__init__(
@@ -114,6 +118,7 @@ def __init__(
114118
termination_condition=termination_condition,
115119
max_turns=max_turns,
116120
runtime=runtime,
121+
custom_message_types=custom_message_types,
117122
emit_team_events=emit_team_events,
118123
)
119124

python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class RoundRobinGroupChat(BaseGroupChat, Component[RoundRobinGroupChatConfig]):
9797
termination_condition (TerminationCondition, optional): The termination condition for the group chat. Defaults to None.
9898
Without a termination condition, the group chat will run indefinitely.
9999
max_turns (int, optional): The maximum number of turns in the group chat before stopping. Defaults to None, meaning no limit.
100+
custom_message_types (List[type[BaseAgentEvent | BaseChatMessage]], optional): A list of custom message types that will be used in the group chat.
101+
If you are using custom message types or your agents produces custom message types, you need to specify them here.
102+
Make sure your custom message types are subclasses of :class:`~autogen_agentchat.messages.BaseAgentEvent` or :class:`~autogen_agentchat.messages.BaseChatMessage`.
100103
emit_team_events (bool, optional): Whether to emit team events through :meth:`BaseGroupChat.run_stream`. Defaults to False.
101104
102105
Raises:

python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ class SelectorGroupChat(BaseGroupChat, Component[SelectorGroupChatConfig]):
328328
max_turns (int, optional): The maximum number of turns in the group chat before stopping. Defaults to None, meaning no limit.
329329
selector_prompt (str, optional): The prompt template to use for selecting the next speaker.
330330
Available fields: '{roles}', '{participants}', and '{history}'.
331+
`{participants}` is the names of candidates for selection. The format is `["<name1>", "<name2>", ...]`.
332+
`{roles}` is a newline-separated list of names and descriptions of the candidate agents. The format for each line is: `"<name> : <description>"`.
333+
`{history}` is the conversation history formatted as a double newline separated of names and message content. The format for each message is: `"<name> : <message content>"`.
331334
allow_repeated_speaker (bool, optional): Whether to include the previous speaker in the list of candidates to be selected for the next turn.
332335
Defaults to False. The model may still select the previous speaker -- a warning will be logged if this happens.
333336
max_selector_attempts (int, optional): The maximum number of attempts to select a speaker using the model. Defaults to 3.
@@ -341,6 +344,9 @@ class SelectorGroupChat(BaseGroupChat, Component[SelectorGroupChatConfig]):
341344
A custom function that takes the conversation history and returns a filtered list of candidates for the next speaker
342345
selection using model. If the function returns an empty list or `None`, `SelectorGroupChat` will raise a `ValueError`.
343346
This function is only used if `selector_func` is not set. The `allow_repeated_speaker` will be ignored if set.
347+
custom_message_types (List[type[BaseAgentEvent | BaseChatMessage]], optional): A list of custom message types that will be used in the group chat.
348+
If you are using custom message types or your agents produces custom message types, you need to specify them here.
349+
Make sure your custom message types are subclasses of :class:`~autogen_agentchat.messages.BaseAgentEvent` or :class:`~autogen_agentchat.messages.BaseChatMessage`.
344350
emit_team_events (bool, optional): Whether to emit team events through :meth:`BaseGroupChat.run_stream`. Defaults to False.
345351
model_client_streaming (bool, optional): Whether to use streaming for the model client. (This is useful for reasoning models like QwQ). Defaults to False.
346352

0 commit comments

Comments
 (0)