From 3f053ee4fcad14c234ddd8d32f28320e486c31ea Mon Sep 17 00:00:00 2001 From: alliscode Date: Thu, 5 Feb 2026 14:41:31 -0800 Subject: [PATCH 1/3] Fix GroupChat orchestrator message cleanup issue Apply clean_conversation_for_handoff to GroupChatOrchestrator and AgentBasedGroupChatOrchestrator _handle_response methods to remove tool-related content that causes API errors from empty messages. Fixes #3705 --- .../packages/core/agent_framework/_workflows/_group_chat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/packages/core/agent_framework/_workflows/_group_chat.py b/python/packages/core/agent_framework/_workflows/_group_chat.py index 3f92d9ebf2..ab1bbcd85a 100644 --- a/python/packages/core/agent_framework/_workflows/_group_chat.py +++ b/python/packages/core/agent_framework/_workflows/_group_chat.py @@ -47,6 +47,7 @@ from ._conversation_state import decode_chat_messages, encode_chat_messages from ._executor import Executor from ._orchestration_request_info import AgentApprovalExecutor +from ._orchestrator_helpers import clean_conversation_for_handoff from ._workflow import Workflow from ._workflow_builder import WorkflowBuilder from ._workflow_context import WorkflowContext @@ -193,6 +194,8 @@ async def _handle_response( ) -> None: """Handle a participant response.""" messages = self._process_participant_response(response) + # Remove tool-related content to prevent API errors from empty messages + messages = clean_conversation_for_handoff(messages) self._append_messages(messages) if await self._check_terminate_and_yield(cast(WorkflowContext[Never, list[ChatMessage]], ctx)): @@ -360,6 +363,8 @@ async def _handle_response( ) -> None: """Handle a participant response.""" messages = self._process_participant_response(response) + # Remove tool-related content to prevent API errors from empty messages + messages = clean_conversation_for_handoff(messages) self._append_messages(messages) if await self._check_terminate_and_yield(cast(WorkflowContext[Never, list[ChatMessage]], ctx)): return From c1f851a80824f7b3b51ada85db47d11793cf7130 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Fri, 6 Feb 2026 12:30:48 +0900 Subject: [PATCH 2/3] Move orchestration related files to orchestrations package. --- .../agent_framework/_workflows/__init__.py | 14 ----------- .../orchestrations/__init__.py | 11 ++++++++ .../__init__.py | 19 ++++++++++++++ .../_base_group_chat_orchestrator.py | 10 ++++---- .../_concurrent.py | 5 ++-- .../_group_chat.py | 25 ++++++++++--------- .../_handoff.py | 5 ++-- .../_magentic.py | 17 +++++++------ .../_orchestration_request_info.py | 20 +++++++-------- .../_orchestration_state.py | 6 ++--- .../_orchestrator_helpers.py | 2 +- .../_sequential.py | 5 ++-- .../orchestrations/tests/test_group_chat.py | 7 +++--- .../orchestrations/tests/test_magentic.py | 2 +- .../tests}/test_orchestration_request_info.py | 6 ++--- 15 files changed, 88 insertions(+), 66 deletions(-) rename python/packages/{core/agent_framework/_workflows => orchestrations/agent_framework_orchestrations}/_base_group_chat_orchestrator.py (98%) rename python/packages/{core/agent_framework/_workflows => orchestrations/agent_framework_orchestrations}/_orchestration_request_info.py (87%) rename python/packages/{core/agent_framework/_workflows => orchestrations/agent_framework_orchestrations}/_orchestration_state.py (92%) rename python/packages/{core/agent_framework/_workflows => orchestrations/agent_framework_orchestrations}/_orchestrator_helpers.py (98%) rename python/packages/{core/tests/workflow => orchestrations/tests}/test_orchestration_request_info.py (99%) diff --git a/python/packages/core/agent_framework/_workflows/__init__.py b/python/packages/core/agent_framework/_workflows/__init__.py index c0aa1833f5..b77a3d4c72 100644 --- a/python/packages/core/agent_framework/_workflows/__init__.py +++ b/python/packages/core/agent_framework/_workflows/__init__.py @@ -7,12 +7,6 @@ AgentExecutorResponse, ) from ._agent_utils import resolve_agent_id -from ._base_group_chat_orchestrator import ( - BaseGroupChatOrchestrator, - GroupChatRequestMessage, - GroupChatRequestSentEvent, - GroupChatResponseReceivedEvent, -) from ._checkpoint import ( CheckpointStorage, FileCheckpointStorage, @@ -65,8 +59,6 @@ handler, ) from ._function_executor import FunctionExecutor, executor -from ._orchestration_request_info import AgentRequestInfoResponse -from ._orchestration_state import OrchestrationState from ._request_info_mixin import response_handler from ._runner import Runner from ._runner_context import ( @@ -97,8 +89,6 @@ "AgentExecutor", "AgentExecutorRequest", "AgentExecutorResponse", - "AgentRequestInfoResponse", - "BaseGroupChatOrchestrator", "Case", "CheckpointStorage", "Default", @@ -115,13 +105,9 @@ "FileCheckpointStorage", "FunctionExecutor", "GraphConnectivityError", - "GroupChatRequestMessage", - "GroupChatRequestSentEvent", - "GroupChatResponseReceivedEvent", "InMemoryCheckpointStorage", "InProcRunnerContext", "Message", - "OrchestrationState", "RequestInfoEvent", "Runner", "RunnerContext", diff --git a/python/packages/core/agent_framework/orchestrations/__init__.py b/python/packages/core/agent_framework/orchestrations/__init__.py index ac141eed72..6e220bac93 100644 --- a/python/packages/core/agent_framework/orchestrations/__init__.py +++ b/python/packages/core/agent_framework/orchestrations/__init__.py @@ -17,6 +17,17 @@ "HandoffBuilder", "HandoffConfiguration", "HandoffSentEvent", + # Base orchestrator + "BaseGroupChatOrchestrator", + "GroupChatRequestMessage", + "GroupChatRequestSentEvent", + "GroupChatResponseReceivedEvent", + "TerminationCondition", + # Orchestration helpers + "AgentRequestInfoResponse", + "OrchestrationState", + "clean_conversation_for_handoff", + "create_completion_message", # Group Chat "AgentBasedGroupChatOrchestrator", "AgentOrchestrationOutput", diff --git a/python/packages/orchestrations/agent_framework_orchestrations/__init__.py b/python/packages/orchestrations/agent_framework_orchestrations/__init__.py index 75c8c8de61..d1acb7af53 100644 --- a/python/packages/orchestrations/agent_framework_orchestrations/__init__.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/__init__.py @@ -17,6 +17,13 @@ except importlib.metadata.PackageNotFoundError: __version__ = "0.0.0" # Fallback for development mode +from ._base_group_chat_orchestrator import ( + BaseGroupChatOrchestrator, + GroupChatRequestMessage, + GroupChatRequestSentEvent, + GroupChatResponseReceivedEvent, + TerminationCondition, +) from ._concurrent import ConcurrentBuilder from ._group_chat import ( AgentBasedGroupChatOrchestrator, @@ -53,6 +60,9 @@ MagenticResetSignal, StandardMagenticManager, ) +from ._orchestration_request_info import AgentRequestInfoResponse +from ._orchestration_state import OrchestrationState +from ._orchestrator_helpers import clean_conversation_for_handoff, create_completion_message from ._sequential import SequentialBuilder __all__ = [ @@ -63,9 +73,14 @@ "ORCH_MSG_KIND_USER_TASK", "AgentBasedGroupChatOrchestrator", "AgentOrchestrationOutput", + "AgentRequestInfoResponse", + "BaseGroupChatOrchestrator", "ConcurrentBuilder", "GroupChatBuilder", "GroupChatOrchestrator", + "GroupChatRequestMessage", + "GroupChatRequestSentEvent", + "GroupChatResponseReceivedEvent", "GroupChatSelectionFunction", "GroupChatState", "HandoffAgentExecutor", @@ -85,7 +100,11 @@ "MagenticProgressLedger", "MagenticProgressLedgerItem", "MagenticResetSignal", + "OrchestrationState", "SequentialBuilder", "StandardMagenticManager", + "TerminationCondition", "__version__", + "clean_conversation_for_handoff", + "create_completion_message", ] diff --git a/python/packages/core/agent_framework/_workflows/_base_group_chat_orchestrator.py b/python/packages/orchestrations/agent_framework_orchestrations/_base_group_chat_orchestrator.py similarity index 98% rename from python/packages/core/agent_framework/_workflows/_base_group_chat_orchestrator.py rename to python/packages/orchestrations/agent_framework_orchestrations/_base_group_chat_orchestrator.py index a1a1ea6b91..5dc01cf242 100644 --- a/python/packages/core/agent_framework/_workflows/_base_group_chat_orchestrator.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_base_group_chat_orchestrator.py @@ -12,14 +12,14 @@ from dataclasses import dataclass from typing import Any, ClassVar, TypeAlias +from agent_framework._types import ChatMessage +from agent_framework._workflows._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse +from agent_framework._workflows._events import WorkflowEvent +from agent_framework._workflows._executor import Executor, handler +from agent_framework._workflows._workflow_context import WorkflowContext from typing_extensions import Never -from .._types import ChatMessage -from ._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse -from ._events import WorkflowEvent -from ._executor import Executor, handler from ._orchestration_request_info import AgentApprovalExecutor -from ._workflow_context import WorkflowContext if sys.version_info >= (3, 12): from typing import override # type: ignore # pragma: no cover diff --git a/python/packages/orchestrations/agent_framework_orchestrations/_concurrent.py b/python/packages/orchestrations/agent_framework_orchestrations/_concurrent.py index d426afd415..20149435d4 100644 --- a/python/packages/orchestrations/agent_framework_orchestrations/_concurrent.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_concurrent.py @@ -12,12 +12,13 @@ from agent_framework._workflows._checkpoint import CheckpointStorage from agent_framework._workflows._executor import Executor, handler from agent_framework._workflows._message_utils import normalize_messages_input -from agent_framework._workflows._orchestration_request_info import AgentApprovalExecutor from agent_framework._workflows._workflow import Workflow from agent_framework._workflows._workflow_builder import WorkflowBuilder from agent_framework._workflows._workflow_context import WorkflowContext from typing_extensions import Never +from ._orchestration_request_info import AgentApprovalExecutor + logger = logging.getLogger(__name__) """Concurrent builder for agent-only fan-out/fan-in workflows. @@ -481,7 +482,7 @@ def with_request_info( Returns: Self for fluent chaining """ - from agent_framework._workflows._orchestration_request_info import resolve_request_info_filter + from ._orchestration_request_info import resolve_request_info_filter self._request_info_enabled = True self._request_info_filter = resolve_request_info_filter(list(agents) if agents else None) diff --git a/python/packages/orchestrations/agent_framework_orchestrations/_group_chat.py b/python/packages/orchestrations/agent_framework_orchestrations/_group_chat.py index 157013e90d..d1d98b9e18 100644 --- a/python/packages/orchestrations/agent_framework_orchestrations/_group_chat.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_group_chat.py @@ -31,26 +31,27 @@ from agent_framework._types import ChatMessage from agent_framework._workflows._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse from agent_framework._workflows._agent_utils import resolve_agent_id -from agent_framework._workflows._base_group_chat_orchestrator import ( - BaseGroupChatOrchestrator, - GroupChatParticipantMessage, - GroupChatRequestMessage, - GroupChatResponseMessage, - GroupChatWorkflowContextOutT, - ParticipantRegistry, - TerminationCondition, -) from agent_framework._workflows._checkpoint import CheckpointStorage from agent_framework._workflows._conversation_state import decode_chat_messages, encode_chat_messages from agent_framework._workflows._executor import Executor -from agent_framework._workflows._orchestration_request_info import AgentApprovalExecutor -from agent_framework._workflows._orchestrator_helpers import clean_conversation_for_handoff from agent_framework._workflows._workflow import Workflow from agent_framework._workflows._workflow_builder import WorkflowBuilder from agent_framework._workflows._workflow_context import WorkflowContext from pydantic import BaseModel, Field from typing_extensions import Never +from ._base_group_chat_orchestrator import ( + BaseGroupChatOrchestrator, + GroupChatParticipantMessage, + GroupChatRequestMessage, + GroupChatResponseMessage, + GroupChatWorkflowContextOutT, + ParticipantRegistry, + TerminationCondition, +) +from ._orchestration_request_info import AgentApprovalExecutor +from ._orchestrator_helpers import clean_conversation_for_handoff + if sys.version_info >= (3, 12): from typing import override # type: ignore # pragma: no cover else: @@ -882,7 +883,7 @@ def with_request_info(self, *, agents: Sequence[str | AgentProtocol] | None = No Returns: Self for fluent chaining """ - from agent_framework._workflows._orchestration_request_info import resolve_request_info_filter + from ._orchestration_request_info import resolve_request_info_filter self._request_info_enabled = True self._request_info_filter = resolve_request_info_filter(list(agents) if agents else None) diff --git a/python/packages/orchestrations/agent_framework_orchestrations/_handoff.py b/python/packages/orchestrations/agent_framework_orchestrations/_handoff.py index 29bc79e30e..9be67a3b52 100644 --- a/python/packages/orchestrations/agent_framework_orchestrations/_handoff.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_handoff.py @@ -43,16 +43,17 @@ from agent_framework._types import AgentResponse, AgentResponseUpdate, ChatMessage from agent_framework._workflows._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse from agent_framework._workflows._agent_utils import resolve_agent_id -from agent_framework._workflows._base_group_chat_orchestrator import TerminationCondition from agent_framework._workflows._checkpoint import CheckpointStorage from agent_framework._workflows._events import WorkflowEvent -from agent_framework._workflows._orchestrator_helpers import clean_conversation_for_handoff from agent_framework._workflows._request_info_mixin import response_handler from agent_framework._workflows._workflow import Workflow from agent_framework._workflows._workflow_builder import WorkflowBuilder from agent_framework._workflows._workflow_context import WorkflowContext from typing_extensions import Never +from ._base_group_chat_orchestrator import TerminationCondition +from ._orchestrator_helpers import clean_conversation_for_handoff + if sys.version_info >= (3, 12): from typing import override # type: ignore # pragma: no cover else: diff --git a/python/packages/orchestrations/agent_framework_orchestrations/_magentic.py b/python/packages/orchestrations/agent_framework_orchestrations/_magentic.py index 3a013a4acd..51996f09a0 100644 --- a/python/packages/orchestrations/agent_framework_orchestrations/_magentic.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_magentic.py @@ -18,14 +18,6 @@ ChatMessage, ) from agent_framework._workflows._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse -from agent_framework._workflows._base_group_chat_orchestrator import ( - BaseGroupChatOrchestrator, - GroupChatParticipantMessage, - GroupChatRequestMessage, - GroupChatResponseMessage, - GroupChatWorkflowContextOutT, - ParticipantRegistry, -) from agent_framework._workflows._checkpoint import CheckpointStorage from agent_framework._workflows._events import ExecutorEvent from agent_framework._workflows._executor import Executor, handler @@ -36,6 +28,15 @@ from agent_framework._workflows._workflow_context import WorkflowContext from typing_extensions import Never +from ._base_group_chat_orchestrator import ( + BaseGroupChatOrchestrator, + GroupChatParticipantMessage, + GroupChatRequestMessage, + GroupChatResponseMessage, + GroupChatWorkflowContextOutT, + ParticipantRegistry, +) + if sys.version_info >= (3, 12): from typing import override # type: ignore # pragma: no cover else: diff --git a/python/packages/core/agent_framework/_workflows/_orchestration_request_info.py b/python/packages/orchestrations/agent_framework_orchestrations/_orchestration_request_info.py similarity index 87% rename from python/packages/core/agent_framework/_workflows/_orchestration_request_info.py rename to python/packages/orchestrations/agent_framework_orchestrations/_orchestration_request_info.py index 314182f53a..4ff4f2565a 100644 --- a/python/packages/core/agent_framework/_workflows/_orchestration_request_info.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_orchestration_request_info.py @@ -2,16 +2,16 @@ from dataclasses import dataclass -from .._agents import AgentProtocol -from .._types import ChatMessage -from ._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse -from ._agent_utils import resolve_agent_id -from ._executor import Executor, handler -from ._request_info_mixin import response_handler -from ._workflow import Workflow -from ._workflow_builder import WorkflowBuilder -from ._workflow_context import WorkflowContext -from ._workflow_executor import WorkflowExecutor +from agent_framework._agents import AgentProtocol +from agent_framework._types import ChatMessage +from agent_framework._workflows._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse +from agent_framework._workflows._agent_utils import resolve_agent_id +from agent_framework._workflows._executor import Executor, handler +from agent_framework._workflows._request_info_mixin import response_handler +from agent_framework._workflows._workflow import Workflow +from agent_framework._workflows._workflow_builder import WorkflowBuilder +from agent_framework._workflows._workflow_context import WorkflowContext +from agent_framework._workflows._workflow_executor import WorkflowExecutor def resolve_request_info_filter(agents: list[str | AgentProtocol] | None) -> set[str]: diff --git a/python/packages/core/agent_framework/_workflows/_orchestration_state.py b/python/packages/orchestrations/agent_framework_orchestrations/_orchestration_state.py similarity index 92% rename from python/packages/core/agent_framework/_workflows/_orchestration_state.py rename to python/packages/orchestrations/agent_framework_orchestrations/_orchestration_state.py index 8210d7d4bb..95894d37dc 100644 --- a/python/packages/core/agent_framework/_workflows/_orchestration_state.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_orchestration_state.py @@ -9,7 +9,7 @@ from dataclasses import dataclass, field from typing import Any -from .._types import ChatMessage +from agent_framework._types import ChatMessage def _new_chat_message_list() -> list[ChatMessage]: @@ -57,7 +57,7 @@ def to_dict(self) -> dict[str, Any]: Returns: Dict with encoded conversation and metadata for persistence """ - from ._conversation_state import encode_chat_messages + from agent_framework._workflows._conversation_state import encode_chat_messages result: dict[str, Any] = { "conversation": encode_chat_messages(self.conversation), @@ -78,7 +78,7 @@ def from_dict(cls, data: dict[str, Any]) -> "OrchestrationState": Returns: Restored OrchestrationState instance """ - from ._conversation_state import decode_chat_messages + from agent_framework._workflows._conversation_state import decode_chat_messages task = None if "task" in data: diff --git a/python/packages/core/agent_framework/_workflows/_orchestrator_helpers.py b/python/packages/orchestrations/agent_framework_orchestrations/_orchestrator_helpers.py similarity index 98% rename from python/packages/core/agent_framework/_workflows/_orchestrator_helpers.py rename to python/packages/orchestrations/agent_framework_orchestrations/_orchestrator_helpers.py index 18d2a07f01..c48af3c6de 100644 --- a/python/packages/core/agent_framework/_workflows/_orchestrator_helpers.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_orchestrator_helpers.py @@ -8,7 +8,7 @@ import logging -from .._types import ChatMessage +from agent_framework._types import ChatMessage logger = logging.getLogger(__name__) diff --git a/python/packages/orchestrations/agent_framework_orchestrations/_sequential.py b/python/packages/orchestrations/agent_framework_orchestrations/_sequential.py index f619473857..b54ddea6d6 100644 --- a/python/packages/orchestrations/agent_framework_orchestrations/_sequential.py +++ b/python/packages/orchestrations/agent_framework_orchestrations/_sequential.py @@ -53,11 +53,12 @@ handler, ) from agent_framework._workflows._message_utils import normalize_messages_input -from agent_framework._workflows._orchestration_request_info import AgentApprovalExecutor from agent_framework._workflows._workflow import Workflow from agent_framework._workflows._workflow_builder import WorkflowBuilder from agent_framework._workflows._workflow_context import WorkflowContext +from ._orchestration_request_info import AgentApprovalExecutor + logger = logging.getLogger(__name__) @@ -235,7 +236,7 @@ def with_request_info( Returns: Self for fluent chaining """ - from agent_framework._workflows._orchestration_request_info import resolve_request_info_filter + from ._orchestration_request_info import resolve_request_info_filter self._request_info_enabled = True self._request_info_filter = resolve_request_info_filter(list(agents) if agents else None) diff --git a/python/packages/orchestrations/tests/test_group_chat.py b/python/packages/orchestrations/tests/test_group_chat.py index 44485f4abf..77e707d6f7 100644 --- a/python/packages/orchestrations/tests/test_group_chat.py +++ b/python/packages/orchestrations/tests/test_group_chat.py @@ -6,12 +6,10 @@ import pytest from agent_framework import ( AgentExecutorResponse, - AgentRequestInfoResponse, AgentResponse, AgentResponseUpdate, AgentThread, BaseAgent, - BaseGroupChatOrchestrator, ChatAgent, ChatMessage, ChatResponse, @@ -24,6 +22,8 @@ ) from agent_framework._workflows._checkpoint import InMemoryCheckpointStorage from agent_framework.orchestrations import ( + AgentRequestInfoResponse, + BaseGroupChatOrchestrator, GroupChatBuilder, GroupChatState, MagenticContext, @@ -1143,9 +1143,10 @@ def test_group_chat_with_orchestrator_factory_returning_base_orchestrator(): def orchestrator_factory() -> BaseGroupChatOrchestrator: nonlocal factory_call_count factory_call_count += 1 - from agent_framework._workflows._base_group_chat_orchestrator import ParticipantRegistry from agent_framework.orchestrations import GroupChatOrchestrator + from agent_framework_orchestrations._base_group_chat_orchestrator import ParticipantRegistry + # Create a custom orchestrator; when returning BaseGroupChatOrchestrator, # the builder uses it as-is without modifying its participant registry return GroupChatOrchestrator( diff --git a/python/packages/orchestrations/tests/test_magentic.py b/python/packages/orchestrations/tests/test_magentic.py index 67106b9011..58943cdad4 100644 --- a/python/packages/orchestrations/tests/test_magentic.py +++ b/python/packages/orchestrations/tests/test_magentic.py @@ -15,7 +15,6 @@ ChatMessage, Content, Executor, - GroupChatRequestMessage, RequestInfoEvent, Workflow, WorkflowCheckpoint, @@ -29,6 +28,7 @@ ) from agent_framework._workflows._checkpoint import InMemoryCheckpointStorage from agent_framework.orchestrations import ( + GroupChatRequestMessage, MagenticBuilder, MagenticContext, MagenticManagerBase, diff --git a/python/packages/core/tests/workflow/test_orchestration_request_info.py b/python/packages/orchestrations/tests/test_orchestration_request_info.py similarity index 99% rename from python/packages/core/tests/workflow/test_orchestration_request_info.py rename to python/packages/orchestrations/tests/test_orchestration_request_info.py index 268b6ce355..83aff7c288 100644 --- a/python/packages/core/tests/workflow/test_orchestration_request_info.py +++ b/python/packages/orchestrations/tests/test_orchestration_request_info.py @@ -7,7 +7,6 @@ from unittest.mock import AsyncMock, MagicMock import pytest - from agent_framework import ( AgentProtocol, AgentResponse, @@ -16,13 +15,14 @@ ChatMessage, ) from agent_framework._workflows._agent_executor import AgentExecutorRequest, AgentExecutorResponse -from agent_framework._workflows._orchestration_request_info import ( +from agent_framework._workflows._workflow_context import WorkflowContext + +from agent_framework_orchestrations._orchestration_request_info import ( AgentApprovalExecutor, AgentRequestInfoExecutor, AgentRequestInfoResponse, resolve_request_info_filter, ) -from agent_framework._workflows._workflow_context import WorkflowContext class TestResolveRequestInfoFilter: From 93d1a8e2c3a940b7caf5f5066620237858a7b534 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Fri, 6 Feb 2026 12:37:46 +0900 Subject: [PATCH 3/3] Fix imports --- .../orchestrations/__init__.pyi | 136 +++++------------- .../agents_with_approval_requests.py | 3 +- .../concurrent_request_info.py | 3 +- .../group_chat_request_info.py | 3 +- .../sequential_request_info.py | 3 +- 5 files changed, 39 insertions(+), 109 deletions(-) diff --git a/python/packages/core/agent_framework/orchestrations/__init__.pyi b/python/packages/core/agent_framework/orchestrations/__init__.pyi index 2ab4a3cc6e..fcaaf04d00 100644 --- a/python/packages/core/agent_framework/orchestrations/__init__.pyi +++ b/python/packages/core/agent_framework/orchestrations/__init__.pyi @@ -1,108 +1,39 @@ # Copyright (c) Microsoft. All rights reserved. -# Type stubs for lazy-loaded orchestrations module -# These re-export types from agent_framework_orchestrations - -from agent_framework_orchestrations import ( - # Magentic - MAGENTIC_MANAGER_NAME as MAGENTIC_MANAGER_NAME, -) -from agent_framework_orchestrations import ( - ORCH_MSG_KIND_INSTRUCTION as ORCH_MSG_KIND_INSTRUCTION, -) -from agent_framework_orchestrations import ( - ORCH_MSG_KIND_NOTICE as ORCH_MSG_KIND_NOTICE, -) -from agent_framework_orchestrations import ( - ORCH_MSG_KIND_TASK_LEDGER as ORCH_MSG_KIND_TASK_LEDGER, -) -from agent_framework_orchestrations import ( - ORCH_MSG_KIND_USER_TASK as ORCH_MSG_KIND_USER_TASK, -) -from agent_framework_orchestrations import ( - # Group Chat - AgentBasedGroupChatOrchestrator as AgentBasedGroupChatOrchestrator, -) -from agent_framework_orchestrations import ( - AgentOrchestrationOutput as AgentOrchestrationOutput, -) -from agent_framework_orchestrations import ( - # Concurrent - ConcurrentBuilder as ConcurrentBuilder, -) -from agent_framework_orchestrations import ( - GroupChatBuilder as GroupChatBuilder, -) -from agent_framework_orchestrations import ( - GroupChatOrchestrator as GroupChatOrchestrator, -) -from agent_framework_orchestrations import ( - GroupChatSelectionFunction as GroupChatSelectionFunction, -) -from agent_framework_orchestrations import ( - GroupChatState as GroupChatState, -) -from agent_framework_orchestrations import ( - # Handoff - HandoffAgentExecutor as HandoffAgentExecutor, -) -from agent_framework_orchestrations import ( - HandoffAgentUserRequest as HandoffAgentUserRequest, -) -from agent_framework_orchestrations import ( - HandoffBuilder as HandoffBuilder, -) -from agent_framework_orchestrations import ( - HandoffConfiguration as HandoffConfiguration, -) -from agent_framework_orchestrations import ( - HandoffSentEvent as HandoffSentEvent, -) -from agent_framework_orchestrations import ( - MagenticAgentExecutor as MagenticAgentExecutor, -) -from agent_framework_orchestrations import ( - MagenticBuilder as MagenticBuilder, -) -from agent_framework_orchestrations import ( - MagenticContext as MagenticContext, -) -from agent_framework_orchestrations import ( - MagenticManagerBase as MagenticManagerBase, -) -from agent_framework_orchestrations import ( - MagenticOrchestrator as MagenticOrchestrator, -) -from agent_framework_orchestrations import ( - MagenticOrchestratorEvent as MagenticOrchestratorEvent, -) -from agent_framework_orchestrations import ( - MagenticOrchestratorEventType as MagenticOrchestratorEventType, -) -from agent_framework_orchestrations import ( - MagenticPlanReviewRequest as MagenticPlanReviewRequest, -) -from agent_framework_orchestrations import ( - MagenticPlanReviewResponse as MagenticPlanReviewResponse, -) -from agent_framework_orchestrations import ( - MagenticProgressLedger as MagenticProgressLedger, -) -from agent_framework_orchestrations import ( - MagenticProgressLedgerItem as MagenticProgressLedgerItem, -) -from agent_framework_orchestrations import ( - MagenticResetSignal as MagenticResetSignal, -) -from agent_framework_orchestrations import ( - # Sequential - SequentialBuilder as SequentialBuilder, -) -from agent_framework_orchestrations import ( - StandardMagenticManager as StandardMagenticManager, -) from agent_framework_orchestrations import ( - __version__ as __version__, + MAGENTIC_MANAGER_NAME, + ORCH_MSG_KIND_INSTRUCTION, + ORCH_MSG_KIND_NOTICE, + ORCH_MSG_KIND_TASK_LEDGER, + ORCH_MSG_KIND_USER_TASK, + AgentBasedGroupChatOrchestrator, + AgentOrchestrationOutput, + AgentRequestInfoResponse, + ConcurrentBuilder, + GroupChatBuilder, + GroupChatOrchestrator, + GroupChatSelectionFunction, + GroupChatState, + HandoffAgentExecutor, + HandoffAgentUserRequest, + HandoffBuilder, + HandoffConfiguration, + HandoffSentEvent, + MagenticAgentExecutor, + MagenticBuilder, + MagenticContext, + MagenticManagerBase, + MagenticOrchestrator, + MagenticOrchestratorEvent, + MagenticOrchestratorEventType, + MagenticPlanReviewRequest, + MagenticPlanReviewResponse, + MagenticProgressLedger, + MagenticProgressLedgerItem, + MagenticResetSignal, + SequentialBuilder, + StandardMagenticManager, + __version__, ) __all__ = [ @@ -113,6 +44,7 @@ __all__ = [ "ORCH_MSG_KIND_USER_TASK", "AgentBasedGroupChatOrchestrator", "AgentOrchestrationOutput", + "AgentRequestInfoResponse", "ConcurrentBuilder", "GroupChatBuilder", "GroupChatOrchestrator", diff --git a/python/samples/getting_started/workflows/human-in-the-loop/agents_with_approval_requests.py b/python/samples/getting_started/workflows/human-in-the-loop/agents_with_approval_requests.py index b82f41b545..8f73b26438 100644 --- a/python/samples/getting_started/workflows/human-in-the-loop/agents_with_approval_requests.py +++ b/python/samples/getting_started/workflows/human-in-the-loop/agents_with_approval_requests.py @@ -3,7 +3,7 @@ import asyncio import json from dataclasses import dataclass -from typing import Annotated, Never +from typing import Annotated from agent_framework import ( AgentExecutorResponse, @@ -16,6 +16,7 @@ tool, ) from agent_framework.openai import OpenAIChatClient +from typing_extensions import Never """ Sample: Agents in a workflow with AI functions requiring approval diff --git a/python/samples/getting_started/workflows/human-in-the-loop/concurrent_request_info.py b/python/samples/getting_started/workflows/human-in-the-loop/concurrent_request_info.py index 3591f54933..178fe028a5 100644 --- a/python/samples/getting_started/workflows/human-in-the-loop/concurrent_request_info.py +++ b/python/samples/getting_started/workflows/human-in-the-loop/concurrent_request_info.py @@ -26,15 +26,14 @@ from typing import Any from agent_framework import ( - AgentRequestInfoResponse, ChatMessage, - ConcurrentBuilder, RequestInfoEvent, WorkflowEvent, WorkflowOutputEvent, ) from agent_framework._workflows._agent_executor import AgentExecutorResponse from agent_framework.azure import AzureOpenAIChatClient +from agent_framework.orchestrations import AgentRequestInfoResponse, ConcurrentBuilder from azure.identity import AzureCliCredential # Store chat client at module level for aggregator access diff --git a/python/samples/getting_started/workflows/human-in-the-loop/group_chat_request_info.py b/python/samples/getting_started/workflows/human-in-the-loop/group_chat_request_info.py index 64f45a1072..fb51c5b530 100644 --- a/python/samples/getting_started/workflows/human-in-the-loop/group_chat_request_info.py +++ b/python/samples/getting_started/workflows/human-in-the-loop/group_chat_request_info.py @@ -28,14 +28,13 @@ from agent_framework import ( AgentExecutorResponse, - AgentRequestInfoResponse, ChatMessage, - GroupChatBuilder, RequestInfoEvent, WorkflowEvent, WorkflowOutputEvent, ) from agent_framework.azure import AzureOpenAIChatClient +from agent_framework.orchestrations import AgentRequestInfoResponse, GroupChatBuilder from azure.identity import AzureCliCredential diff --git a/python/samples/getting_started/workflows/human-in-the-loop/sequential_request_info.py b/python/samples/getting_started/workflows/human-in-the-loop/sequential_request_info.py index 2c3c9ebe7f..bc9eff94f9 100644 --- a/python/samples/getting_started/workflows/human-in-the-loop/sequential_request_info.py +++ b/python/samples/getting_started/workflows/human-in-the-loop/sequential_request_info.py @@ -27,14 +27,13 @@ from agent_framework import ( AgentExecutorResponse, - AgentRequestInfoResponse, ChatMessage, RequestInfoEvent, - SequentialBuilder, WorkflowEvent, WorkflowOutputEvent, ) from agent_framework.azure import AzureOpenAIChatClient +from agent_framework.orchestrations import AgentRequestInfoResponse, SequentialBuilder from azure.identity import AzureCliCredential