Skip to content

fix(agentchat): prevent livelock in SelectorGroupChat fallback when allow_repeated_speaker=False#7472

Open
1Ckpwee wants to merge 1 commit intomicrosoft:mainfrom
1Ckpwee:fix/selector-group-chat-livelock
Open

fix(agentchat): prevent livelock in SelectorGroupChat fallback when allow_repeated_speaker=False#7472
1Ckpwee wants to merge 1 commit intomicrosoft:mainfrom
1Ckpwee:fix/selector-group-chat-livelock

Conversation

@1Ckpwee
Copy link
Copy Markdown

@1Ckpwee 1Ckpwee commented Mar 27, 2026

Summary

  • Fix a livelock bug in SelectorGroupChat where the fallback after exhausting max_selector_attempts returns self._previous_speaker even when allow_repeated_speaker=False, causing an infinite loop (A speaks -> selector fails to pick non-A -> falls back to A -> repeat)
  • When allow_repeated_speaker=False and selector attempts are exhausted, the fallback now picks a random participant that is NOT the previous speaker
  • Updated existing test to explicitly set allow_repeated_speaker=True for the case that tests fallback-to-previous behavior
  • Added new test test_selector_group_chat_no_livelock_on_fallback_when_repeated_speaker_disallowed to verify the fix

Fixes #7471

Test plan

  • Existing test test_selector_group_chat_fall_back_to_previous_after_3_attempts continues to pass (now explicitly uses allow_repeated_speaker=True)
  • New test verifies that when allow_repeated_speaker=False and the LLM exhausts all attempts by picking the previous speaker, the fallback selects a different participant
  • Edge case: if only one participant exists, fallback still returns the previous speaker (no alternative available)

🤖 Generated with Claude Code

…ated_speaker=False

When max_selector_attempts is exhausted and allow_repeated_speaker=False,
the fallback incorrectly returns the previous speaker, creating an infinite
loop. Now falls back to a random non-previous participant instead.

Fixes microsoft#7471
@1Ckpwee
Copy link
Copy Markdown
Author

1Ckpwee commented Mar 27, 2026

@1Ckpwee please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SelectorGroupChat livelock: fallback returns excluded previous speaker when allow_repeated_speaker=False

1 participant