-
Notifications
You must be signed in to change notification settings - Fork 474
fix: fix swarm session management integ test. #1155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
tests_integ/test_multiagent_swarm.py
Outdated
|
|
||
| # Clean up | ||
| session_manager.delete_session(session_id) | ||
| # Create fresh agent instances for the second swarm to avoid tool conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would fail if we didn't do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't create a new instance, it won't fire MultiAgentInitializedEvent then we are not reading saved session, lead to we always restart from researcher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But is this not a valid pattern for customers?
app = FastAPI()
agent_1 = Agent(...)
agent_2= Agent(...)
agent_3 = Agent(...)
@app.post("/chat/")
async def chat(request: Request):
swarm = Swarm([agent_1, agent_2, agent_3], session=session_id or uuidv4())
swarm(request.message)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is valid. this creates new instances every call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It creates a new Swarm instance, not agent instances.
Your test is recreating both the Swarm and the agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh my bad, I should clarify this clearly:
- Swarm agent has handoff_tool, so when we reuse agent instance it casue tools name conflicts.
- I overlooked your question, what I wanna say is, for session management purpose, we need new swarm instance for firing
MuliagentIntilizedEvent. - new agent instances requierd is not related to session manager, it related to tool registry.
So, pattern is invalid, you will need new agent instances for satisfying diffrent tool name restriction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swarm agent has handoff_tool, so when we reuse agent instance it casue tools name conflicts.
is this a bug we should fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is our Swarm design, under def _inject_swarm_tools(self) -> None:
To your question, yes I think we should allow user reuse agent instances, then we need to fix it in separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks let me take a look at _inject_swarm_tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we need a tracking ticket for this.
It seems like the following would fail which is surprising.
agent_1 = Agent()
agent_2 = Agent()
swarm_1 = Swarm(agent_1, agent_2)
swarm_2 = Swarm(agent_1, agent_2)
Description
Rewrite this unit test to verify swarm session management behavior.
Now this test resume from where it stopped.
Related Issues
Documentation PR
Type of Change
Bug fix
New feature
Breaking change
Documentation update
Other (please describe):
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.