AutoGen SelectorGroupChat Not Maintaining Agent Continuity for Health-Related Chat Flow #5683
Unanswered
glarunsingh
asked this question in
Q&A
Replies: 1 comment
-
Also created this - #5535 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm building a simple chat application using AutoGen with Flask-SocketIO (
async_mode='eventlet'
) to integrate real-time communication. The setup includes two agents: aSupervisorAgent
(for routing and general queries) and aHealthcareAgent
(for health-related queries). The goal is a seamless health-focused conversation where:SupervisorAgent
only responds to the initial message (e.g., greeting) or explicit non-health topic shifts (e.g., "What’s the time?").HealthcareAgent
handles all health-related messages and their follow-ups once a health topic is introduced, based on conversation history.However, the
SelectorGroupChat
inconsistently routes follow-up messages. After an initial health-related message (e.g., "I have a headache"), subsequent responses like "It’s mild around my temples" or "Yes to light" are sometimes routed toSupervisorAgent
instead ofHealthcareAgent
, disrupting the conversation flow. TheSupervisorAgent
shouldn’t comment during health discussions—it should silently route toHealthcareAgent
.Scenario
User: I have a headache
Healthcare: How would you describe the headache—sharp, dull, or throbbing?
User: It’s mild around my temples
Healthcare: Thanks for the details. How long has it lasted?
User: Yes to light
Healthcare: Sensitivity to light could indicate a migraine. How long has it been?
SupervisorAgent
interrupts health follow-ups with routing messages like "Please wait for the HealthcareAgent," even though the context is clearly health-related.Current Response
Here’s the latest terminal output I’m getting:
Running updated script with improved selector logic
(17019) wsgi starting up on http://127.0.0.1:5000
...
Result: TaskResult(messages=[TextMessage(source='user', ..., content='i have head ache', ...), TextMessage(source='HealthcareAgent', ..., content="I'm sorry to hear that. How would you describe the headache—sharp, dull, or throbbing? And how long have you been experiencing it?", ...)], stop_reason='Maximum number of turns 1 reached.')
user: i have head ache
Healthcare: I'm sorry to hear that. How would you describe the headache—sharp, dull, or throbbing? And how long have you been experiencing it?
Result: TaskResult(messages=[TextMessage(source='user', ..., content='its mild around my temples', ...), TextMessage(source='SupervisorAgent', ..., content='Please wait for the HealthcareAgent to assist you with that.', ...)], stop_reason='Maximum number of turns 1 reached.')
user: its mild around my temples
Supervisor: Please wait for the HealthcareAgent to assist you with that.
Result: TaskResult(messages=[TextMessage(source='user', ..., content='ok', ...), TextMessage(source='HealthcareAgent', ..., content='Mild headaches around the temples can be due to tension or stress. Have you experienced any other symptoms, like sensitivity to light or nausea?', ...)], stop_reason='Maximum number of turns 1 reached.')
user: ok
Healthcare: Mild headaches around the temples can be due to tension or stress. Have you experienced any other symptoms, like sensitivity to light or nausea?
Result: TaskResult(messages=[TextMessage(source='user', ..., content='yes to light', ...), TextMessage(source='SupervisorAgent', ..., content='Please continue discussing your symptoms with the HealthcareAgent for proper guidance.', ...)], stop_reason='Maximum number of turns 1 reached.')
user: yes to light
Supervisor: Please continue discussing your symptoms with the HealthcareAgent for proper guidance.
What’s Happening
Initial Health Query: "i have head ache" correctly triggers HealthcareAgent.
Follow-Up Issues: "its mild around my temples" and "yes to light" are routed to SupervisorAgent, which responds with routing messages instead of letting HealthcareAgent continue seamlessly.
Selector Failure: Despite a refined selector_prompt emphasizing {history} and agent stickiness, the selector still picks SupervisorAgent for health follow-ups, suggesting a deeper issue with how SelectorGroupChat interprets context or applies the prompt.
Possible Solutions to Triage
I’ve tried refining the selector_prompt multiple times, but the issue persists. Could the community suggest:
Prompt Optimization: Is there a more effective selector_prompt to ensure HealthcareAgent persists for health-related follow-ups without SupervisorAgent interrupting? Perhaps a stricter syntax or additional context cues?
Manual State Tracking: Should I bypass SelectorGroupChat’s built-in selector and implement a manual state tracker (e.g., a variable tracking the current topic) to force HealthcareAgent after a health topic starts? How would this integrate with team.run?
Alternative Approach: Would using team.run_stream with explicit agent selection (instead of team.run with a selector) provide better control over agent continuity? Any examples of this approach?
Debugging Selector Decisions: Is there a way to log the selector’s reasoning (e.g., why it chose SupervisorAgent) to diagnose its logic? This could help pinpoint where it’s misinterpreting {history}.
Any insights or code snippets to triage this would be greatly appreciated! I’d like to avoid SupervisorAgent responses entirely once a health topic is active, ensuring a smooth chat flow with HealthcareAgent.
Current Code
Here’s the simplified code I’m using:
Beta Was this translation helpful? Give feedback.
All reactions