autogen
autogen copied to clipboard
fix: graphflow prematurly completing by adding triggered_activation_groups to the team's state
Consider this simple graph
Node A has two edges with activation_conditions loopback and next.
Node B is a leaf node.
Both nodes are autogen agents.
Node A always emits a stop message response with a text that activate loopback edge.
- Current behavior
# create_flow returns a team, which consists of two agents as per depicted pic above
team_one = create_flow()
result_one: TaskResult = await team_one.run(task="Start")
# As expected the graph will terminate due to the `StopMessage`
assert result_one.stop_reason == "Stop message received"
# And if I run team_one again the graph will terminate due to the `StopMessage` (as expected)
result_one: TaskResult = await team_one.run(task="Continue")
assert result_one.stop_reason == "Stop message received"
# Let's export state from one team and loads it into another.
# Which is useful when we want to stop for human in the loop without a process hanging.
team_two = create_flow()
await team_two.load_state(await team_one.save_state())
# But now the graph stopped due to execution complete instead
result_two: TaskResult = await team_two.run(task="Continue")
assert result_two.stop_reason == "Digraph execution is complete"
- Expected behavior
# Both graphs must stop due to `StopMessage`
assert result_one.stop_reason == "Stop message received"
assert result_two.stop_reason == "Stop message received"
Why are these changes needed?
Consistent behavior.
Related issue number
Maybe #7043
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.
@microsoft-github-policy-service agree
I analyzed this issue but couldn't identify the affected files. Could you please provide more details about which files need to be modified?