Skip to content

fix: return consistent List[str] from SwarmGroupChatManager.select_speaker#7582

Open
Ricardo-M-L wants to merge 1 commit intomicrosoft:mainfrom
Ricardo-M-L:fix/swarm-select-speaker-return-type
Open

fix: return consistent List[str] from SwarmGroupChatManager.select_speaker#7582
Ricardo-M-L wants to merge 1 commit intomicrosoft:mainfrom
Ricardo-M-L:fix/swarm-select-speaker-return-type

Conversation

@Ricardo-M-L
Copy link
Copy Markdown

Why Are These Changes Needed?

SwarmGroupChatManager.select_speaker() has inconsistent return types:

  • Lines 91, 97: return [self._current_speaker] (List[str])
  • Line 98: return self._current_speaker (str)

The return type annotation is List[str] | str, but the docstring says "This method always returns a single speaker." Callers that process the result uniformly as a list will get a TypeError when the fallback path returns a bare string.

Related issue number

N/A

Checks

  • I've included any doc changes needed
  • I've added tests (if applicable) corresponding to the changes introduced in this PR
  • I've made sure all auto checks have passed

…eaker

The method returns List[str] when thread is empty (line 91) or when a
HandoffMessage is found (line 97), but returns a bare str when no
handoff message exists (line 98). This inconsistency can cause TypeError
in callers expecting a uniform return type.

Wrap the fallback return in a list to match the other return paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant