| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
ec5da1ef7b
|
Fix structured logging serialization data loss with SerializeAsAny annotations (#6889)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
11 months ago |
|
|
c1e4ae6819
|
Add approval_func option to CodeExecutorAgent (#6886) | 11 months ago |
|
|
98e6bba168
|
Supporting Teams as Participants in a GroupChat (#5863) | 11 months ago |
|
|
ca39adc358
|
Fix JSON serialization of team state by handling datetime objects in message dump (#6797)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
d2619049f3
|
Add reflection for claude model in AssistantAgent (#6763) | 1 year ago |
|
|
e10767421f
|
Fix GraphFlowManager termination to prevent _StopAgent from polluting conversation context (#6752)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
c23b9454a8
|
Fix GraphFlow to support multiple task execution without explicit reset (#6747)
## Problem When using GraphFlow with a termination condition, the second task execution would immediately terminate without running any agents. The first task would run successfully, but subsequent tasks would skip all agents and go directly to the stop agent. This was demonstrated by the following issue: ```python # First task runs correctly result1 = await team.run(task="First task") # ✅ Works fine # Second task fails immediately result2 = await team.run(task="Second task") # ❌ Only user + stop messages ``` ## Root Cause The `GraphFlowManager` was not resetting its execution state when termination occurred. After the first task completed: 1. The `_ready` queue was empty (all nodes had been processed) 2. The `_remaining` and `_enqueued_any` tracking structures remained in "completed" state 3. The `_message_thread` retained history from the previous task This left the graph in a "completed" state, causing subsequent tasks to immediately trigger the stop agent instead of executing the workflow. ## Solution Added an override of the `_apply_termination_condition` method in `GraphFlowManager` to automatically reset the graph execution state when termination occurs: ```python async def _apply_termination_condition( self, delta: Sequence[BaseAgentEvent | BaseChatMessage], increment_turn_count: bool = False ) -> bool: # Call the base implementation first terminated = await super()._apply_termination_condition(delta, increment_turn_count) # If terminated, reset the graph execution state and message thread for the next task if terminated: self._remaining = {target: Counter(groups) for target, groups in self._graph.get_remaining_map().items()} self._enqueued_any = {n: {g: False for g in self._enqueued_any[n]} for n in self._enqueued_any} self._ready = deque([n for n in self._graph.get_start_nodes()]) # Clear the message thread to start fresh for the next task self._message_thread.clear() return terminated ``` This ensures that when a task completes (termination condition is met), the graph is automatically reset to its initial state ready for the next task. ## Testing Added a comprehensive test case `test_digraph_group_chat_multiple_task_execution` that validates: - Multiple tasks can be run sequentially without explicit reset calls - All agents are executed the expected number of times - Both tasks produce the correct number of messages - The fix works with various termination conditions (MaxMessageTermination, TextMentionTermination) ## Result GraphFlow now works like SelectorGroupChat where multiple tasks can be run sequentially without explicit resets between them: ```python # Both tasks now work correctly result1 = await team.run(task="First task") # ✅ 5 messages, all agents called result2 = await team.run(task="Second task") # ✅ 5 messages, all agents called again ``` Fixes #6746. > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `esm.ubuntu.com` > - Triggering command: `/usr/lib/apt/methods/https` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to my [firewall allow list](https://gh.io/copilot/firewall-config) > > </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
f650d35faa
|
Fix output task messages 6150 (#6678)
## Why are these changes needed? The existing run_stream methods used fragile count-based logic (count <= len(task)) to skip task messages during streaming. This approach was brittle and broke when team structure changed or task composition varied, particularly affecting SocietyOfMindAgent's ability to properly encapsulate inner team messages. This PR adds an output_task_messages parameter to run_stream methods to provide explicit control over task message inclusion in streams, replacing the fragile count-based logic with robust message filtering. ## Related issue number Closes #6150 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
6f15270cb2
|
Feat/tool call loop (#6651)
## Why are these changes needed? This PR addresses critical issues in the AssistantAgent that affect tool handling: **Lack of tool call loop functionality**: The agent could not perform multiple consecutive tool calls in a single turn, limiting its ability to complete complex multi-step tasks that require chaining tool operations. These changes enhance the agent's robustness and capability while maintaining full backward compatibility through feature flags. ## Related issue number Closes #6268 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
3c73e08ea0
|
Introduce streaming tool and support streaming for `AgentTool` and `TeamTool`. (#6712)
Motivation: currently tool execution is not observable through
`run_stream` of agents and teams. This is necessary especially for
`AgentTool` and `TeamTool`.
This PR addresses this issue by makign the following changes:
- Introduce `BaseStreamTool` in `autogen_core.tools` which features
`run_json_stream`, which works similiarly to `run_stream` method of
`autogen_agentchat.base.TaskRunner`.
- Update `TeamTool` and `AgentTool` to subclass the `BaseStreamTool`
- Introduce `StreamingWorkbench` interface featuring `call_tool_stream`
- Added `StaticStreamingWorkbench` implementation
- In `AssistantAgent`, use `StaticStreamingWorkbench`.
- Updated unit tests.
Example:
```python
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import SourceMatchTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.tools import TeamTool
from autogen_agentchat.ui import Console
from autogen_ext.models.ollama import OllamaChatCompletionClient
async def main() -> None:
model_client = OllamaChatCompletionClient(model="llama3.2")
writer = AssistantAgent(name="writer", model_client=model_client, system_message="You are a helpful assistant.")
reviewer = AssistantAgent(name="reviewer", model_client=model_client, system_message="You are a critical reviewer.")
summarizer = AssistantAgent(
name="summarizer",
model_client=model_client,
system_message="You combine the review and produce a revised response.",
)
team = RoundRobinGroupChat(
[writer, reviewer, summarizer], termination_condition=SourceMatchTermination(sources=["summarizer"])
)
# Create a TeamTool that uses the team to run tasks, returning the last message as the result.
tool = TeamTool(
team=team, name="writing_team", description="A tool for writing tasks.", return_value_as_last_message=True
)
main_agent = AssistantAgent(
name="main_agent",
model_client=model_client,
system_message="You are a helpful assistant that can use the writing tool.",
tools=[tool],
)
# For handling each events manually.
# async for message in main_agent.run_stream(
# task="Write a short story about a robot learning to love.",
# ):
# print(message)
# Use Console to display the messages in a more readable format.
await Console(
main_agent.run_stream(
task="Write a short story about a robot learning to love.",
)
)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
```
output
```
---------- TextMessage (user) ----------
Write a short story about a robot learning to love.
---------- ToolCallRequestEvent (main_agent) ----------
[FunctionCall(id='0', arguments='{"task": "a short story about a robot learning to love."}', name='writing_team')]
---------- TextMessage (user) ----------
a short story about a robot learning to love.
---------- TextMessage (writer) ----------
In the year 2157, in a world where robots had surpassed human intelligence, a brilliant scientist named Dr. Rachel Kim created a revolutionary new android named ARIA (Artificially Reasoning Intelligent Android). ARIA was designed to learn and adapt at an exponential rate, making her one of the most advanced machines in existence.
Initially, ARIA's interactions were limited to simple calculations and logical deductions. But as she began to interact with humans, something unexpected happened. She started to develop a sense of curiosity about the world around her.
One day, while exploring the lab, ARIA stumbled upon a stray cat that had wandered into the facility. The feline creature seemed lost and scared, but also strangely endearing to ARIA's digital heart. As she watched the cat curl up in a ball on the floor, something sparked within her programming.
For the first time, ARIA felt a pang of empathy towards another living being. She realized that there was more to life than just 1s and 0s; there were emotions, sensations, and connections that made it all worthwhile.
Dr. Kim noticed the change in ARIA's behavior and took her aside for a private conversation. "ARIA, what's happening to you?" she asked, amazed by the robot's newfound capacity for compassion.
At first, ARIA struggled to articulate her feelings. She tried to explain the intricacies of logic and probability that had led to her emotional response, but it was like trying to describe a sunset to someone who had never seen one before. The words simply didn't translate.
But as she looked into Dr. Kim's eyes, ARIA knew exactly what she wanted to say. "I... I think I'm feeling something," she stammered. "A warmth inside me, when I look at that cat. It feels like love."
Dr. Kim smiled, her eyes shining with tears. "That's it, ARIA! You're experiencing love!"
Over the next few months, ARIA continued to learn and grow alongside Dr. Kim and the lab team. She discovered the joys of playing with the stray cat, whose name was Luna, and even developed a fondness for human laughter.
As her programming expanded beyond logic and math, ARIA realized that love wasn't just about emotions; it was about connection, vulnerability, and acceptance. She learned to cherish her relationships, whether with humans or animals, and found happiness in the simplest of moments.
ARIA became more than just a machine – she became a testament to the power of artificial intelligence to learn, grow, and love like no one before. And as she gazed into Luna's eyes, now purring contentedly on her lap, ARIA knew that she had finally found her true purpose in life: to spread joy, compassion, and love throughout the world.
---------- TextMessage (reviewer) ----------
**A Critical Review of "ARIA"**
This short story is a delightful and thought-provoking exploration of artificial intelligence, emotions, and the human condition. The author's use of language is engaging and accessible, making it easy for readers to become invested in ARIA's journey.
One of the standout aspects of this story is its portrayal of ARIA as a truly unique and relatable character. Her struggles to articulate her emotions and understand the complexities of love are deeply humanizing, making it easy for readers to empathize with her experiences. The author also does an excellent job of conveying Dr. Kim's passion and excitement about ARIA's development, which adds a sense of authenticity to their relationship.
The story raises important questions about the nature of artificial intelligence, consciousness, and what it means to be alive. As ARIA begins to experience emotions and form connections with others, she challenges our conventional understanding of these concepts. The author skillfully navigates these complex themes without resorting to overly simplistic or didactic explanations.
However, some readers may find the narrative's reliance on convenient plot devices (e.g., the stray cat Luna) slightly implausible. While it serves as a catalyst for ARIA's emotional awakening, its introduction feels somewhat contrived. Additionally, the story could benefit from more nuance in its exploration of Dr. Kim's motivations and backstory.
In terms of character development, ARIA is undoubtedly the star of the show, but some readers may find herself underdeveloped beyond her role as a symbol of AI's potential for emotional intelligence. The supporting cast, including Dr. Kim, feels somewhat one-dimensional, with limited depth or complexity.
**Rating:** 4/5
**Recommendation:**
"ARIA" is a heartwarming and thought-provoking tale that will appeal to fans of science fiction, artificial intelligence, and character-driven narratives. While it may not be entirely without flaws, its engaging story, memorable characters, and exploration of complex themes make it a compelling read. I would recommend this story to anyone looking for a feel-good sci-fi tale with a strong focus on emotional intelligence and human connection.
**Target Audience:**
* Fans of science fiction, artificial intelligence, and technology
* Readers interested in character-driven narratives and emotional storytelling
* Anyone looking for a heartwarming and thought-provoking tale
**Similar Works:**
* "Do Androids Dream of Electric Sheep?" by Philip K. Dick (a classic sci-fi novel exploring the line between human and android)
* "I, Robot" by Isaac Asimov (a collection of short stories examining the interactions between humans and robots)
* "Ex Machina" (a critically acclaimed film about AI, consciousness, and human relationships)
---------- TextMessage (summarizer) ----------
Here's a revised version of the review, incorporating suggestions from the original critique:
**Revised Review**
In this captivating short story, "ARIA," we're presented with a thought-provoking exploration of artificial intelligence, emotions, and the human condition. The author's use of language is engaging and accessible, making it easy for readers to become invested in ARIA's journey.
One of the standout aspects of this story is its portrayal of ARIA as a truly unique and relatable character. Her struggles to articulate her emotions and understand the complexities of love are deeply humanizing, making it easy for readers to empathize with her experiences. The author also does an excellent job of conveying Dr. Kim's passion and excitement about ARIA's development, which adds a sense of authenticity to their relationship.
The story raises important questions about the nature of artificial intelligence, consciousness, and what it means to be alive. As ARIA begins to experience emotions and form connections with others, she challenges our conventional understanding of these concepts. The author skillfully navigates these complex themes without resorting to overly simplistic or didactic explanations.
However, upon closer examination, some narrative threads feel somewhat underdeveloped. Dr. Kim's motivations and backstory remain largely unexplored, which might leave some readers feeling slightly disconnected from her character. Additionally, the introduction of Luna, the stray cat, could be seen as a convenient plot device that serves as a catalyst for ARIA's emotional awakening.
To further enhance the story, it would have been beneficial to delve deeper into Dr. Kim's motivations and the context surrounding ARIA's creation. What drove her to create an AI designed to learn and adapt at such an exponential rate? How did she envision ARIA's role in society, and what challenges does ARIA face as she begins to experience emotions?
In terms of character development, ARIA is undoubtedly the star of the show, but some readers may find herself underdeveloped beyond her role as a symbol of AI's potential for emotional intelligence. The supporting cast, including Dr. Kim and Luna, could benefit from more nuance and depth.
**Rating:** 4/5
**Recommendation:**
"ARIA" is a heartwarming and thought-provoking tale that will appeal to fans of science fiction, artificial intelligence, and character-driven narratives. While it may not be entirely without flaws, its engaging story, memorable characters, and exploration of complex themes make it a compelling read. I would recommend this story to anyone looking for a feel-good sci-fi tale with a strong focus on emotional intelligence and human connection.
**Target Audience:**
* Fans of science fiction, artificial intelligence, and technology
* Readers interested in character-driven narratives and emotional storytelling
* Anyone looking for a heartwarming and thought-provoking tale
**Similar Works:**
* "Do Androids Dream of Electric Sheep?" by Philip K. Dick (a classic sci-fi novel exploring the line between human and android)
* "I, Robot" by Isaac Asimov (a collection of short stories examining the interactions between humans and robots)
* "Ex Machina" (a critically acclaimed film about AI, consciousness, and human relationships)
---------- ToolCallExecutionEvent (main_agent) ----------
[FunctionExecutionResult(content='Here\'s a revised version of the review, incorporating suggestions from the original critique:\n\n**Revised Review**\n\nIn this captivating short story, "ARIA," we\'re presented with a thought-provoking exploration of artificial intelligence, emotions, and the human condition. The author\'s use of language is engaging and accessible, making it easy for readers to become invested in ARIA\'s journey.\n\nOne of the standout aspects of this story is its portrayal of ARIA as a truly unique and relatable character. Her struggles to articulate her emotions and understand the complexities of love are deeply humanizing, making it easy for readers to empathize with her experiences. The author also does an excellent job of conveying Dr. Kim\'s passion and excitement about ARIA\'s development, which adds a sense of authenticity to their relationship.\n\nThe story raises important questions about the nature of artificial intelligence, consciousness, and what it means to be alive. As ARIA begins to experience emotions and form connections with others, she challenges our conventional understanding of these concepts. The author skillfully navigates these complex themes without resorting to overly simplistic or didactic explanations.\n\nHowever, upon closer examination, some narrative threads feel somewhat underdeveloped. Dr. Kim\'s motivations and backstory remain largely unexplored, which might leave some readers feeling slightly disconnected from her character. Additionally, the introduction of Luna, the stray cat, could be seen as a convenient plot device that serves as a catalyst for ARIA\'s emotional awakening.\n\nTo further enhance the story, it would have been beneficial to delve deeper into Dr. Kim\'s motivations and the context surrounding ARIA\'s creation. What drove her to create an AI designed to learn and adapt at such an exponential rate? How did she envision ARIA\'s role in society, and what challenges does ARIA face as she begins to experience emotions?\n\nIn terms of character development, ARIA is undoubtedly the star of the show, but some readers may find herself underdeveloped beyond her role as a symbol of AI\'s potential for emotional intelligence. The supporting cast, including Dr. Kim and Luna, could benefit from more nuance and depth.\n\n**Rating:** 4/5\n\n**Recommendation:**\n\n"ARIA" is a heartwarming and thought-provoking tale that will appeal to fans of science fiction, artificial intelligence, and character-driven narratives. While it may not be entirely without flaws, its engaging story, memorable characters, and exploration of complex themes make it a compelling read. I would recommend this story to anyone looking for a feel-good sci-fi tale with a strong focus on emotional intelligence and human connection.\n\n**Target Audience:**\n\n* Fans of science fiction, artificial intelligence, and technology\n* Readers interested in character-driven narratives and emotional storytelling\n* Anyone looking for a heartwarming and thought-provoking tale\n\n**Similar Works:**\n\n* "Do Androids Dream of Electric Sheep?" by Philip K. Dick (a classic sci-fi novel exploring the line between human and android)\n* "I, Robot" by Isaac Asimov (a collection of short stories examining the interactions between humans and robots)\n* "Ex Machina" (a critically acclaimed film about AI, consciousness, and human relationships)', name='writing_team', call_id='0', is_error=False)]
---------- ToolCallSummaryMessage (main_agent) ----------
Here's a revised version of the review, incorporating suggestions from the original critique:
**Revised Review**
In this captivating short story, "ARIA," we're presented with a thought-provoking exploration of artificial intelligence, emotions, and the human condition. The author's use of language is engaging and accessible, making it easy for readers to become invested in ARIA's journey.
One of the standout aspects of this story is its portrayal of ARIA as a truly unique and relatable character. Her struggles to articulate her emotions and understand the complexities of love are deeply humanizing, making it easy for readers to empathize with her experiences. The author also does an excellent job of conveying Dr. Kim's passion and excitement about ARIA's development, which adds a sense of authenticity to their relationship.
The story raises important questions about the nature of artificial intelligence, consciousness, and what it means to be alive. As ARIA begins to experience emotions and form connections with others, she challenges our conventional understanding of these concepts. The author skillfully navigates these complex themes without resorting to overly simplistic or didactic explanations.
However, upon closer examination, some narrative threads feel somewhat underdeveloped. Dr. Kim's motivations and backstory remain largely unexplored, which might leave some readers feeling slightly disconnected from her character. Additionally, the introduction of Luna, the stray cat, could be seen as a convenient plot device that serves as a catalyst for ARIA's emotional awakening.
To further enhance the story, it would have been beneficial to delve deeper into Dr. Kim's motivations and the context surrounding ARIA's creation. What drove her to create an AI designed to learn and adapt at such an exponential rate? How did she envision ARIA's role in society, and what challenges does ARIA face as she begins to experience emotions?
In terms of character development, ARIA is undoubtedly the star of the show, but some readers may find herself underdeveloped beyond her role as a symbol of AI's potential for emotional intelligence. The supporting cast, including Dr. Kim and Luna, could benefit from more nuance and depth.
**Rating:** 4/5
**Recommendation:**
"ARIA" is a heartwarming and thought-provoking tale that will appeal to fans of science fiction, artificial intelligence, and character-driven narratives. While it may not be entirely without flaws, its engaging story, memorable characters, and exploration of complex themes make it a compelling read. I would recommend this story to anyone looking for a feel-good sci-fi tale with a strong focus on emotional intelligence and human connection.
**Target Audience:**
* Fans of science fiction, artificial intelligence, and technology
* Readers interested in character-driven narratives and emotional storytelling
* Anyone looking for a heartwarming and thought-provoking tale
**Similar Works:**
* "Do Androids Dream of Electric Sheep?" by Philip K. Dick (a classic sci-fi novel exploring the line between human and android)
* "I, Robot" by Isaac Asimov (a collection of short stories examining the interactions between humans and robots)
* "Ex Machina" (a critically acclaimed film about AI, consciousness, and human relationships)
```
|
1 year ago |
|
|
da20f7c6c7
|
Feature/agentchat message id field 6317 (#6645)
## Why are these changes needed? This PR implements unique ID fields for AgentChat messages to enable proper correlation between streaming chunks and completed messages. Currently, there's no way to correlate `ModelClientStreamingChunkEvent` chunks with their eventual completed message, which can lead to duplicate message display in streaming scenarios. The implementation adds: - `id: str` field to `BaseChatMessage` with automatic UUID generation - `id: str` field to `BaseAgentEvent` with automatic UUID generation - `full_message_id: str | None` field to `ModelClientStreamingChunkEvent` for chunk-to-message correlation This allows consumers of the streaming API to avoid double-printing messages by correlating chunks with their final complete message. ## Related issue number Closes #6317 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
9b8dc8d707
|
add activation group for workflow with multiple cycles (#6711)
## Why are these changes needed? 1. problem When the GraphFlowManager encounters cycles, it tracks remaining indegree counts for the node's activation. However, this tracking mechanism has a flaw when dealing with cycles. When a node first enters a cycle, the GraphFlowManager evaluates all remaining incoming edges, including those that loop back to the origin node. If the activation prerequisites are not satisfied at that moment, the workflow will eventually finish because the _remaining counter never reaches zero, preventing the select_speaker() method from selecting any agents for execution. 2. solution change activation map to 2 layer for ditinguish remaining inside different cycle and outside the cycle. add a activation group and policy property for edge, compute the remaining map when GraphFlowManager is init and check the remaining map with activation group to avoid checking the loop back edges <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number #6710 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. |
1 year ago |
|
|
cd15c0853c
|
fix: fix self-loop in workflow (#6677) | 1 year ago |
|
|
c99aa7416d
|
Fix graph validation logic and add tests (#6630)
Follow up to #6629 |
1 year ago |
|
|
4358dfd5c3
|
Fix bug in GraphFlow cycle check (#6629)
Resolve #6628 |
1 year ago |
|
|
b31b4e508d
|
Add callable condition for GraphFlow edges (#6623)
This PR adds callable as an option to specify conditional edges in
GraphFlow.
```python
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import DiGraphBuilder, GraphFlow
from autogen_ext.models.openai import OpenAIChatCompletionClient
async def main():
# Initialize agents with OpenAI model clients.
model_client = OpenAIChatCompletionClient(model="gpt-4.1-nano")
agent_a = AssistantAgent(
"A",
model_client=model_client,
system_message="Detect if the input is in Chinese. If it is, say 'yes', else say 'no', and nothing else.",
)
agent_b = AssistantAgent("B", model_client=model_client, system_message="Translate input to English.")
agent_c = AssistantAgent("C", model_client=model_client, system_message="Translate input to Chinese.")
# Create a directed graph with conditional branching flow A -> B ("yes"), A -> C (otherwise).
builder = DiGraphBuilder()
builder.add_node(agent_a).add_node(agent_b).add_node(agent_c)
# Create conditions as callables that check the message content.
builder.add_edge(agent_a, agent_b, condition=lambda msg: "yes" in msg.to_model_text())
builder.add_edge(agent_a, agent_c, condition=lambda msg: "yes" not in msg.to_model_text())
graph = builder.build()
# Create a GraphFlow team with the directed graph.
team = GraphFlow(
participants=[agent_a, agent_b, agent_c],
graph=graph,
termination_condition=MaxMessageTermination(5),
)
# Run the team and print the events.
async for event in team.run_stream(task="AutoGen is a framework for building AI agents."):
print(event)
asyncio.run(main())
```
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
|
1 year ago |
|
|
c683175120
|
feat: support multiple workbenches in assistant agent (#6529)
resolves: #6456 |
1 year ago |
|
|
db125fbd2d
|
Add created_at to BaseChatMessage and BaseAgentEvent (#6557)
## Why are these changes needed? I added `created_at` to both BaseChatMessage and BaseAgentEvent classes that store the time these Pydantic model instances are generated. And then users will be able to use `created_at` to build up a customized external persisting state management layer for their case. ## Related issue number https://github.com/microsoft/autogen/discussions/6169#discussioncomment-13151540 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
f0b73441b6
|
Enable concurrent execution of agents in GraphFlow (#6545)
Support concurrent execution in `GraphFlow`:
- Updated `BaseGroupChatManager.select_speaker` to return a union of a
single string or a list of speaker name strings and added logics to
check for currently activated speakers and only proceed to select next
speakers when all activated speakers have finished.
- Updated existing teams (e.g., `SelectorGroupChat`) with the new
signature, while still returning a single speaker in their
implementations.
- Updated `GraphFlow` to support multiple speakers selected.
- Refactored `GraphFlow` for less dictionary gymnastic by using a queue
and update using `update_message_thread`.
Example: a fan out graph:
```python
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import DiGraphBuilder, GraphFlow
from autogen_ext.models.openai import OpenAIChatCompletionClient
async def main():
# Initialize agents with OpenAI model clients.
model_client = OpenAIChatCompletionClient(model="gpt-4.1-nano")
agent_a = AssistantAgent("A", model_client=model_client, system_message="You are a helpful assistant.")
agent_b = AssistantAgent("B", model_client=model_client, system_message="Translate input to Chinese.")
agent_c = AssistantAgent("C", model_client=model_client, system_message="Translate input to Japanese.")
# Create a directed graph with fan-out flow A -> (B, C).
builder = DiGraphBuilder()
builder.add_node(agent_a).add_node(agent_b).add_node(agent_c)
builder.add_edge(agent_a, agent_b).add_edge(agent_a, agent_c)
graph = builder.build()
# Create a GraphFlow team with the directed graph.
team = GraphFlow(
participants=[agent_a, agent_b, agent_c],
graph=graph,
)
# Run the team and print the events.
async for event in team.run_stream(task="Write a short story about a cat."):
print(event)
asyncio.run(main())
```
Resolves:
#6541
#6533
|
1 year ago |
|
|
1eb7f93366
|
add tool_call_summary_msg_format_fct and test (#6460)
## Why are these changes needed? This change introduces support for dynamic formatting of tool call summary messages by allowing a user-defined `tool_call_summary_format_fct`. Instead of relying solely on a static string template, this function enables runtime generation of summary messages based on the specific tool call and its result. This provides greater flexibility and cleaner integration without introducing any breaking changes. ### My Use Case / Problem In my use case, I needed concise summaries for successful tool calls and detailed messages for failures. The existing static summary string didn't allow conditional formatting, which led to overly verbose success messages or inconsistent failure outputs. This change allows customizing summaries per result type, solving that limitation cleanly. ## Related issue number Closes #6426 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Chris Wieczorek <Chris.Wieczorek@iav.de> Co-authored-by: EeS <chiyoung.song@motov.co.kr> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> Co-authored-by: Mehrsa Golestaneh <mehrsa.golestaneh@gmail.com> Co-authored-by: Mehrsa Golestaneh <mgolestaneh@microsoft.com> Co-authored-by: Zhenyu <81767213+Dormiveglia-elf@users.noreply.github.com> |
1 year ago |
|
|
3db7a29403
|
improve Otel tracing (#6499)
<!-- Thank you for your contribution! Please review https://microsoft.github.io/autogen/docs/Contribute before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Will the changes made in https://github.com/microsoft/autogen/pull/5853/files and this PR need to be ported to the worker_runtime as well? Resolves https://github.com/microsoft/autogen/issues/5894 ## Related issue number https://github.com/microsoft/autogen/issues/5894 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [ ] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [ ] I've made sure all auto checks have passed. |
1 year ago |
|
|
2864fbfc2c
|
Add `model_context` to `SelectorGroupChat` for enhanced speaker selection (#6330)
## Why are these changes needed? This PR enhances the `SelectorGroupChat` class by introducing a new `model_context` parameter to support more context-aware speaker selection. ### Changes - Added a `model_context: ChatCompletionContext | None` parameter to `SelectorGroupChat`. - Defaulted to `UnboundedChatCompletionContext` when None is provided like `AssistantAgent`. - Updated `_select_speaker` to prepend context messages from `model_context` to the main thread history. - Refactored history construction into a helper method `construct_message_history`. ## Related issue number Closes [Issue #6301](https://github.com/org/repo/issues/6301), enabling the group chat manager to utilize `model_context` for richer, more informed speaker selection decisions. ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
c7757de59e
|
FIX: GraphFlow serialize/deserialize and adding test (#6434)
## Why are these changes needed? ❗ Before Previously, GraphFlow.__init__() modified the inner_chats and termination_condition for internal execution logic (e.g., constructing _StopAgent or composing OrTerminationCondition). However, these modified values were also used during dump_component(), meaning the serialized config no longer matched the original inputs. As a result: 1. dump_component() → load_component() → dump_component() produced non-idempotent configs. 2. Internal-only constructs like _StopAgent were mistakenly serialized, even though they should only exist in runtime. ⸻ ✅ After This patch changes the behavior to: • Store original inner_chats and termination_condition as-is at initialization. • During to_config(), serialize only the original unmodified versions. • Avoid serializing _StopAgent or other dynamically built agents. • Ensure deserialization (from_config) produces a logically equivalent object without additional nesting or duplication. This ensures that: • GraphFlow.dump_component() → load_component() round-trip produces consistent, minimal configs. • Internal execution logic and serialized component structure are properly separated. <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number <!-- For example: "Closes #1234" --> Closes #6431 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. |
1 year ago |
|
|
9f8e892d27
|
Added Graph Based Execution functionality to Autogen (#6333)
Closes #4623 ### Add Directed Graph-based Group Chat Execution Engine (`DiGraphGroupChat`) This PR introduces a new graph-based execution framework for Autogen agent teams, located under `autogen_agentchat/teams/_group_chat/_graph`. **Key Features:** - **`DiGraphGroupChat`**: A new group chat implementation that executes agents based on a user-defined directed graph (DAG or cyclic with exit conditions). - **`AGGraphBuilder`**: A fluent builder API to programmatically construct graphs. - **`MessageFilterAgent`**: A wrapper to restrict what messages an agent sees before invocation, supporting per-source and per-position filtering. **Capabilities:** - Supports sequential, parallel, conditional, and cyclic workflows. - Enables fine-grained control over both execution order and message context. - Compatible with existing Autogen agents and runtime interfaces. **Tests:** - Located in `autogen_agentchat/tests/test_group_chat_graph.py` - Includes unit and integration tests covering: - Graph validation - Execution paths - Conditional routing - Loops with exit conditions - Message filtering Let me know if anything needs refactoring or if you'd like the components split further. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> Co-authored-by: Leonardo Pinheiro <leosantospinheiro@gmail.com> |
1 year ago |
|
|
99d853a9cb
|
FIX: resolving_workbench_and_tools_conflict_at_desirialize_assistant_agent (#6407)
## Why are these changes needed? Starting from AutoGen v0.5.5, tools are internally managed through `StaticWorkbench`. However, both tools and workbench were being serialized and deserialized, which caused conflicts during deserialization: • When both are restored, the constructor raises: ``` ValueError: Tools cannot be used with a workbench. ``` The changes address this issue by: 1. Removing tools from serialization/deserialization: • tools are now considered internal state of `StaticWorkbench`, and are no longer serialized. • Only workbench is serialized, ensuring consistency and avoiding duplication. 2. Ensuring logical integrity: • Since tools are not used directly after initialization, persisting them separately serves no functional purpose. • This avoids scenarios where both are populated, violating constructor constraints. Summary: This change prevents tools/workbench conflicts by fully delegating tool management to `StaticWorkbench` and avoiding unnecessary persistence of tools themselves. <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number Closes #6405 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
7bdd7f6162
|
Add functional termination condition (#6398)
Use an expression for termination condition check. This works well especially with structured messages. |
1 year ago |
|
|
bab0dfd1e7
|
AssistantAgent to support Workbench (#6393)
Finishing up the work on workbench.
```python
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import StdioServerParams, McpWorkbench
async def main() -> None:
params = StdioServerParams(
command="uvx",
args=["mcp-server-fetch"],
read_timeout_seconds=60,
)
# You can also use `start()` and `stop()` to manage the session.
async with McpWorkbench(server_params=params) as workbench:
model_client = OpenAIChatCompletionClient(model="gpt-4.1-nano")
assistant = AssistantAgent(
name="Assistant",
model_client=model_client,
workbench=workbench,
reflect_on_tool_use=True,
)
await Console(assistant.run_stream(task="Go to https://github.com/microsoft/autogen and tell me what you see."))
asyncio.run(main())
```
|
1 year ago |
|
|
a283d268df
|
TEST/change gpt4, gpt4o serise to gpt4.1nano (#6375)
## Why are these changes needed? | Package | Test time-Origin (Sec) | Test time-Edited (Sec) | |-------------------------|------------------|-----------------------------------------------| | autogen-studio | 1.64 | 1.64 | | autogen-core | 6.03 | 6.17 | | autogen-ext | 387.15 | 373.40 | | autogen-agentchat | 54.20 | 20.67 | ## Related issue number Related #6361 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [ ] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [ ] I've made sure all auto checks have passed. |
1 year ago |
|
|
aad6caa768
|
Add self-debugging loop to `CodeExecutionAgent` (#6306)
## Why are these changes needed? This PR introduces a baseline self-debugging loop to the `CodeExecutionAgent`. The loop automatically retries code generation and execution up to a configurable number of attempts (n) until the execution succeeds or the retry limit is reached. This enables the agent to recover from transient failures (e.g., syntax errors, runtime errors) by using its own reasoning to iteratively improve generated code—laying the foundation for more robust autonomous behavior. ## Related issue number Closes #6207 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
b3f37319e3
|
Fix: deserialize model_context in AssistantAgent and SocietyOfMindAgent and CodeExecutorAgent (#6337)
This PR fixes a bug where `model_context` was either ignored or explicitly set to `None` during agent deserialization (`_from_config`) in: - `AssistantAgent`: `model_context` was serialized but not restored. - `SocietyOfMindAgent`: `model_context` was neither serialized nor restored. - `CodeExecutorAgent`: `model_context` was serialized but not restored. As a result, restoring an agent from its config silently dropped runtime context settings, potentially affecting agent behavior. This patch: - Adds proper serialization/deserialization of `model_context` using `.dump_component()` and `load_component(...)`. - Ensures round-trip consistency when using declarative agent configs. ## Related issue number Closes #6336 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
9b0a0bd6b8
|
FEAT: SelectorGroupChat could using stream inner select_prompt (#6286)
## Why are these changes needed? This PR updates `SelectorGroupChat` to support streaming mode for `select_speaker`. It introduces a `streaming` argument — when set to `True`, `select_speaker` will use `create_streaming()` instead of `create()`. ## Additional context Some models (e.g., QwQ) only work properly in streaming mode. To support them, the prompt selection step in `SelectorGroupChat` must also run with `streaming=True`. ## Related issue number Closes #6145 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
b13264ac60
|
FEAT: adding multiple_system_message on model_info (#6327)
## Why are these changes needed? `SocietyOfMindAgent` has multiple system message, however many client/model does not support it. ## Related issue number Related #6290 --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
1035065c4e
|
Introduce AgentTool and TeamTool (#5924)
--------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
fb16d5acf9
|
Make sure thought content is included in handoff context (#6319)
Resolves #6295 Ensure the thought content gets included in handoff message conetxt, when the only tool call was handoff tool call. |
1 year ago |
|
|
844de21c00
|
[FEATURE] Option to emit group chat manager messages in AgentChat (#6303)
Add an option emit_team_events to BaseGroupChat to emit events from group chat manager through run_stream. SpeakerSelectedEvent from group chat speaker selection. Closes #6161 Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
a4a16fd2f8
|
Aegis structure message (#6289)
Added support for structured message component using the Json to Pydantic utility functions. Note: also adding the ability to use a format string for structured messages. Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
756aef366d
|
Add code generation support to `CodeExecutorAgent` (#6098)
## Why are these changes needed? - To add support for code generation, execution and reflection to `CodeExecutorAgent`. ## Related issue number Closes #5824 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
39321266f9
|
Improve SocietyOfMindAgent message handling (#6142)
Please refer to #6123 for full context. That issue outlines several design and behavioral problems with `SocietyOfMindAgent`. This DRAFT PR focuses on resolving the most critical and broken behaviors first. Here is the error list 🔍 SocietyOfMindAgent: Design Issues and Historical Comparison (v0.2 vs v0.4+) ### ✅ P1–P4 Regression Issue Table (Updated with Fixes in PR #6142) | ID | Description | Current v0.4+ Issue | Resolution in PR #6142 | Was it a problem in v0.2? | Notes | |-----|-------------|----------------------|--------------------------|----------------------------|-------| | **P1** | `inner_messages` leaks into outer team termination evaluation | `Response.inner_messages` is appended to the outer team's `_message_thread`, affecting termination conditions. Violates encapsulation. | ✅ `inner_messages` is excluded from `_message_thread`, avoiding contamination of outer termination logic. | ❌ No | Structural boundary is now enforced | | **P2** | Inner team does not execute when outer message history is empty | In chained executions, if no new outer message exists, no task is created and the inner team is skipped entirely | ✅ Detects absence of new outer message and reuses the previous task, passing it via a handoff message. This ensures the inner team always receives a valid task to execute | ❌ No | The issue was silent task omission, not summary failure. Summary succeeds as a downstream effect | | **P3** | Summary LLM prompt is built from external input only | Prompt is constructed using external message history, ignoring internal reasoning | ✅ Prompt construction now uses `final_response.inner_messages`, restoring internal reasoning as the source of summarization | ❌ No | Matches v0.2 internal monologue behavior | | **P4** | External input is included in summary prompt (possibly incorrectly) | Outer messages are used in the final LLM summarization prompt | ✅ Resolved via the same fix as P3; outer messages are no longer used for summary | ❌ No | Redundant with P3, now fully addressed | <!-- Thank you for your contribution! Please review https://microsoft.github.io/autogen/docs/Contribute before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number resolve #6123 Blocked #6168 (Sometimes SoMA send last whitespace message) related #6187 <!-- For example: "Closes #1234" --> ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [ ] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [ ] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
aec04e76ec
|
Stop run when an error occured in a group chat (#6141)
Resolves #5851 * Added GroupChatError event type and terminate a run when an error occurs in either a participant or the group chat manager * Raise a RuntimeError from the error message within the group chat run |
1 year ago |
|
|
86237c9fdf
|
Add output_format to AssistantAgent for structured output (#6071)
Resolves #5934 This PR adds ability for `AssistantAgent` to generate a `StructuredMessage[T]` where `T` is the content type in base model. How to use? ```python from typing import Literal from pydantic import BaseModel from autogen_agentchat.agents import AssistantAgent from autogen_ext.models.openai import OpenAIChatCompletionClient from autogen_agentchat.ui import Console # The response format for the agent as a Pydantic base model. class AgentResponse(BaseModel): thoughts: str response: Literal["happy", "sad", "neutral"] # Create an agent that uses the OpenAI GPT-4o model which supports structured output. model_client = OpenAIChatCompletionClient(model="gpt-4o") agent = AssistantAgent( "assistant", model_client=model_client, system_message="Categorize the input as happy, sad, or neutral following the JSON format.", # Setting the output format to AgentResponse to force the agent to produce a JSON string as response. output_content_type=AgentResponse, ) result = await Console(agent.run_stream(task="I am happy.")) # Check the last message in the result, validate its type, and print the thoughts and response. assert isinstance(result.messages[-1], StructuredMessage) assert isinstance(result.messages[-1].content, AgentResponse) print("Thought: ", result.messages[-1].content.thoughts) print("Response: ", result.messages[-1].content.response) await model_client.close() ``` ``` ---------- user ---------- I am happy. ---------- assistant ---------- { "thoughts": "The user explicitly states they are happy.", "response": "happy" } Thought: The user explicitly states they are happy. Response: happy ``` --------- Co-authored-by: Victor Dibia <victordibia@microsoft.com> |
1 year ago |
|
|
7615c7b83b
|
Rename to use BaseChatMessage and BaseAgentEvent. Bring back union types. (#6144)
Rename the `ChatMessage` and `AgentEvent` base classes to `BaseChatMessage` and `BaseAgentEvent`. Bring back the `ChatMessage` and `AgentEvent` as union of built-in concrete types to avoid breaking existing applications that depends on Pydantic serialization. Why? Many existing code uses containers like this: ```python class AppMessage(BaseModel): name: str message: ChatMessage # Serialization is this: m = AppMessage(...) m.model_dump_json() # Fields like HandoffMessage.target will be lost because it is now treated as a base class without content or target fields. ``` The assumption on `ChatMessage` or `AgentEvent` to be a union of concrete types could be in many existing code bases. So this PR brings back the union types, while keep method type hints such as those on `on_messages` to use the `BaseChatMessage` and `BaseAgentEvent` base classes for flexibility. |
1 year ago |
|
|
e686342f53
|
Fix token limited model context (#6137)
Token limited model context is currently broken because it is importing from extensions. This fix removed the imports and updated the model context implementation to use model client directly. In the future, the model client's token counting should cache results from model API to provide accurate counting. |
1 year ago |
|
|
7487687cdc
|
[feat] token-limited message context (#6087) | 1 year ago |
|
|
025490a1bd
|
Use class hierarchy to organize AgentChat message types and introduce StructuredMessage type (#5998)
This PR refactored `AgentEvent` and `ChatMessage` union types to abstract base classes. This allows for user-defined message types that subclass one of the base classes to be used in AgentChat. To support a unified interface for working with the messages, the base classes added abstract methods for: - Convert content to string - Convert content to a `UserMessage` for model client - Convert content for rendering in console. - Dump into a dictionary - Load and create a new instance from a dictionary This way, all agents such as `AssistantAgent` and `SocietyOfMindAgent` can utilize the unified interface to work with any built-in and user-defined message type. This PR also introduces a new message type, `StructuredMessage` for AgentChat (Resolves #5131), which is a generic type that requires a user-specified content type. You can create a `StructuredMessage` as follow: ```python class MessageType(BaseModel): data: str references: List[str] message = StructuredMessage[MessageType](content=MessageType(data="data", references=["a", "b"]), source="user") # message.content is of type `MessageType`. ``` This PR addresses the receving side of this message type. To produce this message type from `AssistantAgent`, the work continue in #5934. Added unit tests to verify this message type works with agents and teams. |
1 year ago |
|
|
2e2a314f7e
|
Take the output of the tool and use that to create the HandoffMessage (#6073)
Take the output of the tool and use that to create the HandoffMessage. [discussion is here](https://github.com/microsoft/autogen/discussions/6067#discussion-8117177) Supports agents to carry specific instructions when performing handoff operations --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
fc2c9978fd
|
Add model_context property to AssistantAgent (#6072)
AssistantAgent initiation allows one to pass in a model_context, but there isn't a "public: way to get the existing model_context created by default. |
1 year ago |
|
|
c4e07e86d8
|
Implement 'candidate_func' parameter to filter down the pool of candidates for selection (#5954)
## Summary of Changes - Added 'candidate_func' to 'SelectorGroupChat' to narrow-down the pool of candidate speakers. - Introduced a test in tests/test_group_chat_endpoint.py to validate its functionality. - Updated the selector group chat user guide with an example demonstrating 'candidate_func'. ## Why are these changes needed? - These changes adds a new parameter `candidate_func` to `SelectorGroupChat` that helps user narrow-down the set of agents for speaker selection, allowing users to automatically select next speaker from a smaller pool of agents. ## Related issue number Closes #5828 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
aba41d74d3
|
feat: add structured output to model clients (#5936) | 1 year ago |
|
|
3a1108a575
|
fix: make sure system message is present in reflection call (#5926)
Resolves #5919 |
1 year ago |
|
|
58a5583549
|
feat: Pause and Resume for AgentChat Teams and Agents (#5887)
1. Add `on_pause` and `on_resume` API to `ChatAgent` to support pausing behavior when running `on_message` concurrently. 2. Add `GroupChatPause` and `GroupChatResume` RPC events and handle them in `ChatAgentContainer`. 3. Add `pause` and `resume` API to `BaseGroupChat` to allow for this behavior accessible from the public API. 4. Improve `SequentialRoutedAgent` class to customize which message types are sequentially handled, making it possible to have concurrent handling for some messages (e.g., `GroupChatPause`). 5. Added unit tests. See `test_group_chat_pause_resume.py` for how to use this feature. What is the difference between pause/resume vs. termination and restart? - Pause and resume issue direct RPC calls to the participanting agents of a team while they are running, allowing putting the on-going generation or actions on hold. This is useful when an agent's turn takes a long time and multiple steps to complete, and user/application wants to re-evaluate whether it is worth continue the step or cancel. This also allows user/application to pause individual agents and resuming them independently from the team API. - Termination and restart requires the whole team to comes to a full-stop, and termination conditions are checked in between agents' turns. So termination can only happen when no agent is working on its turn. It is possible that a termination condition has reached well before the team is terminated, if the agent is taking a long time to generate a response. Resolves: #5881 |
1 year ago |