mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING] Renamed AgentProtocol to SupportsAgentRun (#3717)
* Renamed AgentProtocol to AgentLike * Resolved comments * Renamed AgentLike to SupportsAgentRun * Resolved comments
This commit is contained in:
committed by
GitHub
Unverified
parent
ac17adb595
commit
15256bb616
@@ -320,7 +320,7 @@ class TestGroupChatBuilder:
|
||||
|
||||
builder = GroupChatBuilder().with_orchestrator(selection_func=selector)
|
||||
|
||||
with pytest.raises(ValueError, match="AgentProtocol participants must have a non-empty name"):
|
||||
with pytest.raises(ValueError, match="SupportsAgentRun participants must have a non-empty name"):
|
||||
builder.participants([agent])
|
||||
|
||||
def test_empty_participant_name_raises_error(self) -> None:
|
||||
@@ -332,7 +332,7 @@ class TestGroupChatBuilder:
|
||||
|
||||
builder = GroupChatBuilder().with_orchestrator(selection_func=selector)
|
||||
|
||||
with pytest.raises(ValueError, match="AgentProtocol participants must have a non-empty name"):
|
||||
with pytest.raises(ValueError, match="SupportsAgentRun participants must have a non-empty name"):
|
||||
builder.participants([agent])
|
||||
|
||||
|
||||
|
||||
@@ -420,7 +420,7 @@ def test_handoff_builder_rejects_mixed_types_in_add_handoff_source():
|
||||
triage = MockHandoffAgent(name="triage")
|
||||
specialist = MockHandoffAgent(name="specialist")
|
||||
|
||||
with pytest.raises(TypeError, match="Cannot mix factory names \\(str\\) and AgentProtocol.*instances"):
|
||||
with pytest.raises(TypeError, match="Cannot mix factory names \\(str\\) and SupportsAgentRun.*instances"):
|
||||
(
|
||||
HandoffBuilder(participants=[triage, specialist])
|
||||
.with_start_agent(triage)
|
||||
|
||||
@@ -7,7 +7,6 @@ from typing import Any, ClassVar, cast
|
||||
|
||||
import pytest
|
||||
from agent_framework import (
|
||||
AgentProtocol,
|
||||
AgentResponse,
|
||||
AgentResponseUpdate,
|
||||
AgentThread,
|
||||
@@ -15,6 +14,7 @@ from agent_framework import (
|
||||
ChatMessage,
|
||||
Content,
|
||||
Executor,
|
||||
SupportsAgentRun,
|
||||
Workflow,
|
||||
WorkflowCheckpoint,
|
||||
WorkflowCheckpointException,
|
||||
@@ -576,7 +576,7 @@ class StubAssistantsAgent(BaseAgent):
|
||||
)
|
||||
|
||||
|
||||
async def _collect_agent_responses_setup(participant: AgentProtocol) -> list[ChatMessage]:
|
||||
async def _collect_agent_responses_setup(participant: SupportsAgentRun) -> list[ChatMessage]:
|
||||
captured: list[ChatMessage] = []
|
||||
|
||||
wf = (
|
||||
@@ -1121,10 +1121,10 @@ async def test_magentic_with_agent_factory():
|
||||
"""Test workflow creation using agent_factory for StandardMagenticManager."""
|
||||
factory_call_count = 0
|
||||
|
||||
def agent_factory() -> AgentProtocol:
|
||||
def agent_factory() -> SupportsAgentRun:
|
||||
nonlocal factory_call_count
|
||||
factory_call_count += 1
|
||||
return cast(AgentProtocol, StubManagerAgent())
|
||||
return cast(SupportsAgentRun, StubManagerAgent())
|
||||
|
||||
participant = StubAgent("agentA", "reply from agentA")
|
||||
workflow = (
|
||||
@@ -1239,10 +1239,10 @@ def test_magentic_agent_factory_with_standard_manager_options():
|
||||
"""Test that agent_factory properly passes through standard manager options."""
|
||||
factory_call_count = 0
|
||||
|
||||
def agent_factory() -> AgentProtocol:
|
||||
def agent_factory() -> SupportsAgentRun:
|
||||
nonlocal factory_call_count
|
||||
factory_call_count += 1
|
||||
return cast(AgentProtocol, StubManagerAgent())
|
||||
return cast(SupportsAgentRun, StubManagerAgent())
|
||||
|
||||
# Custom options to verify they are passed through
|
||||
custom_max_stall_count = 5
|
||||
|
||||
@@ -8,11 +8,11 @@ from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
import pytest
|
||||
from agent_framework import (
|
||||
AgentProtocol,
|
||||
AgentResponse,
|
||||
AgentResponseUpdate,
|
||||
AgentThread,
|
||||
ChatMessage,
|
||||
SupportsAgentRun,
|
||||
)
|
||||
from agent_framework._workflows._agent_executor import AgentExecutorRequest, AgentExecutorResponse
|
||||
from agent_framework._workflows._workflow_context import WorkflowContext
|
||||
@@ -44,10 +44,10 @@ class TestResolveRequestInfoFilter:
|
||||
assert result == {"agent1", "agent2"}
|
||||
|
||||
def test_resolves_agent_display_names(self):
|
||||
"""Test resolving AgentProtocol instances by name attribute."""
|
||||
agent1 = MagicMock(spec=AgentProtocol)
|
||||
"""Test resolving SupportsAgentRun instances by name attribute."""
|
||||
agent1 = MagicMock(spec=SupportsAgentRun)
|
||||
agent1.name = "writer"
|
||||
agent2 = MagicMock(spec=AgentProtocol)
|
||||
agent2 = MagicMock(spec=SupportsAgentRun)
|
||||
agent2.name = "reviewer"
|
||||
|
||||
result = resolve_request_info_filter([agent1, agent2])
|
||||
@@ -55,7 +55,7 @@ class TestResolveRequestInfoFilter:
|
||||
|
||||
def test_mixed_types(self):
|
||||
"""Test resolving a mix of strings and agents."""
|
||||
agent = MagicMock(spec=AgentProtocol)
|
||||
agent = MagicMock(spec=SupportsAgentRun)
|
||||
agent.name = "writer"
|
||||
|
||||
result = resolve_request_info_filter(["manual_name", agent])
|
||||
|
||||
Reference in New Issue
Block a user