Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions python/packages/core/agent_framework/_workflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -97,8 +89,6 @@
"AgentExecutor",
"AgentExecutorRequest",
"AgentExecutorResponse",
"AgentRequestInfoResponse",
"BaseGroupChatOrchestrator",
"Case",
"CheckpointStorage",
"Default",
Expand All @@ -115,13 +105,9 @@
"FileCheckpointStorage",
"FunctionExecutor",
"GraphConnectivityError",
"GroupChatRequestMessage",
"GroupChatRequestSentEvent",
"GroupChatResponseReceivedEvent",
"InMemoryCheckpointStorage",
"InProcRunnerContext",
"Message",
"OrchestrationState",
"RequestInfoEvent",
"Runner",
"RunnerContext",
Expand Down
11 changes: 11 additions & 0 deletions python/packages/core/agent_framework/orchestrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
136 changes: 34 additions & 102 deletions python/packages/core/agent_framework/orchestrations/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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__ = [
Expand All @@ -113,6 +44,7 @@ __all__ = [
"ORCH_MSG_KIND_USER_TASK",
"AgentBasedGroupChatOrchestrator",
"AgentOrchestrationOutput",
"AgentRequestInfoResponse",
"ConcurrentBuilder",
"GroupChatBuilder",
"GroupChatOrchestrator",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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__ = [
Expand All @@ -63,9 +73,14 @@
"ORCH_MSG_KIND_USER_TASK",
"AgentBasedGroupChatOrchestrator",
"AgentOrchestrationOutput",
"AgentRequestInfoResponse",
"BaseGroupChatOrchestrator",
"ConcurrentBuilder",
"GroupChatBuilder",
"GroupChatOrchestrator",
"GroupChatRequestMessage",
"GroupChatRequestSentEvent",
"GroupChatResponseReceivedEvent",
"GroupChatSelectionFunction",
"GroupChatState",
"HandoffAgentExecutor",
Expand All @@ -85,7 +100,11 @@
"MagenticProgressLedger",
"MagenticProgressLedgerItem",
"MagenticResetSignal",
"OrchestrationState",
"SequentialBuilder",
"StandardMagenticManager",
"TerminationCondition",
"__version__",
"clean_conversation_for_handoff",
"create_completion_message",
]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +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._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:
Expand Down Expand Up @@ -192,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)):
Expand Down Expand Up @@ -359,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
Expand Down Expand Up @@ -877,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading
Loading