Repository navigation
Python: Fix group chat docstring examples - #9752
Naveen Chatlapalli (1aifanatic) wants to merge 2 commits into
Conversation
GroupChatOrchestrator takes a ParticipantRegistry of executors, not a list of names, and GroupChatState.participants is a name-to-description mapping that cannot be indexed by position. The checkpointing example imported MemoryCheckpointStorage, which is InMemoryCheckpointStorage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new consumer-facing example uses a private import, violating the repository’s explicit public-import requirement.
1 open issue
What changed in this PR
This documentation-only PR updates two group-chat examples to match the current Agent Framework APIs, without changing runtime behavior.
Changes:
- Construct the orchestrator with agent executors and a participant registry, then build a workflow.
- Select speakers by participant name and import
GroupChatState. - Replace
MemoryCheckpointStoragewithInMemoryCheckpointStorage.
| File | Description |
|---|---|
python/packages/orchestrations/agent_framework_orchestrations/_group_chat.py |
Corrects orchestrator construction, speaker selection, and checkpoint-storage docstring examples. |
Review effort: Balanced
| from agent_framework_orchestrations import GroupChatOrchestrator | ||
| from agent_framework import Agent, AgentExecutor | ||
| from agent_framework_orchestrations import GroupChatBuilder, GroupChatOrchestrator, GroupChatState | ||
| from agent_framework_orchestrations._base_group_chat_orchestrator import ParticipantRegistry |
There was a problem hiding this comment.
Agreed — ParticipantRegistry isn't exported, and the constructor requires one, so there's no public way to call GroupChatOrchestrator(...) directly. Rather than widen the public surface in a docs PR, the example now uses the supported route: GroupChatBuilder(participants=..., selection_func=..., orchestrator_name="Coordinator", max_rounds=10), which builds a GroupChatOrchestrator internally. Ran it with a stub chat client: the built workflow contains a GroupChatOrchestrator named "Coordinator" and the run completes at max_rounds=10. If maintainers would rather export ParticipantRegistry, I can do that in a separate PR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Motivation & Context
Two examples in
agent_framework_orchestrations/_group_chat.pyfail when copied.GroupChatOrchestrator.__init__participants=["researcher", "writer"]. The constructor takesparticipant_registry: ParticipantRegistry, which is built from executors, so the call raisesTypeError: GroupChatOrchestrator.__init__() got an unexpected keyword argument 'participants'.state.participants[state.current_round % len(state.participants)].GroupChatState.participantsis anOrderedDictof name to description, so indexing it by position raisesKeyError: 0.GroupChatStatewithout importing it.GroupChatBuilder.with_checkpointingMemoryCheckpointStoragefromagent_framework. That name doesn't exist; the class isInMemoryCheckpointStorage.Description & Review Guide
samples/03-workflows/orchestrations/group_chat_simple_selector.py: select speakers by name withlist(state.participants)and build the orchestrator throughGroupChatBuilder(participants=..., selection_func=..., orchestrator_name=..., max_rounds=...), which constructs aGroupChatOrchestrator. This avoids importing the non-exportedParticipantRegistry.InMemoryCheckpointStoragein the checkpointing example.GroupChatOrchestratordirectly needsParticipantRegistry, which the package doesn't export; I can export it in a separate PR if you'd prefer the direct form.I ran both corrected examples with a stub chat client. The orchestrator workflow contains a
GroupChatOrchestratornamed "Coordinator" and stops atmax_rounds. The checkpointed builder workflow wrote checkpoints toInMemoryCheckpointStorage. I found these by type-checking the code examples in the package docstrings.Related Issue
N/A - trivial change: docstring examples are corrected to the current constructor and class names, with no behavior change.
AI Assistance
AI assistance details: Claude Code helped find these by type-checking the docstring examples, run the corrected examples against a stub client, make the edits, and draft this description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.🤖 Generated with Claude Code