Python: [BREAKING] Renamed AgentProtocol to SupportsAgentRun (#3717)

* Renamed AgentProtocol to AgentLike

* Resolved comments

* Renamed AgentLike to SupportsAgentRun

* Resolved comments
This commit is contained in:
Dmytro Struk
2026-02-06 09:53:21 -08:00
committed by GitHub
Unverified
parent ac17adb595
commit 15256bb616
55 changed files with 354 additions and 354 deletions
@@ -9,12 +9,12 @@ from datetime import datetime, timezone
from typing import Any, cast
from agent_framework import (
AgentProtocol,
AgentResponse,
AgentResponseUpdate,
ChatMessage,
Content,
ResponseStream,
SupportsAgentRun,
get_logger,
)
from durabletask.entities import DurableEntity
@@ -86,12 +86,12 @@ class AgentEntity:
This class encapsulates the core logic for executing an agent within a durable entity context.
"""
agent: AgentProtocol
agent: SupportsAgentRun
callback: AgentResponseCallbackProtocol | None
def __init__(
self,
agent: AgentProtocol,
agent: SupportsAgentRun,
callback: AgentResponseCallbackProtocol | None = None,
*,
state_provider: AgentEntityStateProviderMixin,
@@ -2,7 +2,7 @@
"""Durable Agent Shim for Durable Task Framework.
This module provides the DurableAIAgent shim that implements AgentProtocol
This module provides the DurableAIAgent shim that implements SupportsAgentRun
and provides a consistent interface for both Client and Orchestration contexts.
The actual execution is delegated to the context-specific providers.
"""
@@ -12,7 +12,7 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Generic, Literal, TypeVar
from agent_framework import AgentProtocol, AgentThread, ChatMessage
from agent_framework import AgentThread, ChatMessage, SupportsAgentRun
from ._executors import DurableAgentExecutor
from ._models import DurableAgentThread
@@ -47,11 +47,11 @@ class DurableAgentProvider(ABC, Generic[TaskT]):
raise NotImplementedError("Subclasses must implement get_agent()")
class DurableAIAgent(AgentProtocol, Generic[TaskT]):
class DurableAIAgent(SupportsAgentRun, Generic[TaskT]):
"""A durable agent proxy that delegates execution to the provider.
This class implements AgentProtocol but with one critical difference:
- AgentProtocol.run() returns a Coroutine (async, must await)
This class implements SupportsAgentRun but with one critical difference:
- SupportsAgentRun.run() returns a Coroutine (async, must await)
- DurableAIAgent.run() returns TaskT (sync Task object - must yield
or the AgentResponse directly in the case of TaskHubGrpcClient)
@@ -104,8 +104,8 @@ class DurableAIAgent(AgentProtocol, Generic[TaskT]):
Additional keys are forwarded to the agent execution.
Note:
This method overrides AgentProtocol.run() with a different return type:
- AgentProtocol.run() returns Coroutine[Any, Any, AgentResponse] (async)
This method overrides SupportsAgentRun.run() with a different return type:
- SupportsAgentRun.run() returns Coroutine[Any, Any, AgentResponse] (async)
- DurableAIAgent.run() returns TaskT (Task object for yielding)
This is intentional to support orchestration contexts that use yield patterns
@@ -11,7 +11,7 @@ from __future__ import annotations
import asyncio
from typing import Any
from agent_framework import AgentProtocol, get_logger
from agent_framework import SupportsAgentRun, get_logger
from durabletask.worker import TaskHubGrpcWorker
from ._callbacks import AgentResponseCallbackProtocol
@@ -60,12 +60,12 @@ class DurableAIAgentWorker:
"""
self._worker = worker
self._callback = callback
self._registered_agents: dict[str, AgentProtocol] = {}
self._registered_agents: dict[str, SupportsAgentRun] = {}
logger.debug("[DurableAIAgentWorker] Initialized with worker type: %s", type(worker).__name__)
def add_agent(
self,
agent: AgentProtocol,
agent: SupportsAgentRun,
callback: AgentResponseCallbackProtocol | None = None,
) -> None:
"""Register an agent with the worker.
@@ -139,7 +139,7 @@ class DurableAIAgentWorker:
def __create_agent_entity(
self,
agent: AgentProtocol,
agent: SupportsAgentRun,
callback: AgentResponseCallbackProtocol | None = None,
) -> type[DurableTaskEntityStateProvider]:
"""Factory function to create a DurableEntity class configured with an agent.
@@ -9,7 +9,7 @@ Run with: pytest tests/test_client.py -v
from unittest.mock import Mock
import pytest
from agent_framework import AgentProtocol
from agent_framework import SupportsAgentRun
from agent_framework_durabletask import DurableAgentThread, DurableAIAgentClient
from agent_framework_durabletask._constants import DEFAULT_MAX_POLL_RETRIES, DEFAULT_POLL_INTERVAL_SECONDS
@@ -46,7 +46,7 @@ class TestDurableAIAgentClientGetAgent:
agent = agent_client.get_agent("assistant")
assert isinstance(agent, DurableAIAgent)
assert isinstance(agent, AgentProtocol)
assert isinstance(agent, SupportsAgentRun)
def test_get_agent_shim_has_correct_name(self, agent_client: DurableAIAgentClient) -> None:
"""Verify retrieved agent has the correct name."""
@@ -9,7 +9,7 @@ Run with: pytest tests/test_orchestration_context.py -v
from unittest.mock import Mock
import pytest
from agent_framework import AgentProtocol
from agent_framework import SupportsAgentRun
from agent_framework_durabletask import DurableAgentThread
from agent_framework_durabletask._orchestration_context import DurableAIAgentOrchestrationContext
@@ -36,7 +36,7 @@ class TestDurableAIAgentOrchestrationContextGetAgent:
agent = agent_context.get_agent("assistant")
assert isinstance(agent, DurableAIAgent)
assert isinstance(agent, AgentProtocol)
assert isinstance(agent, SupportsAgentRun)
def test_get_agent_shim_has_correct_name(self, agent_context: DurableAIAgentOrchestrationContext) -> None:
"""Verify retrieved agent has the correct name."""
@@ -10,7 +10,7 @@ from typing import Any
from unittest.mock import Mock
import pytest
from agent_framework import AgentProtocol, ChatMessage
from agent_framework import ChatMessage, SupportsAgentRun
from pydantic import BaseModel
from agent_framework_durabletask import DurableAgentThread
@@ -142,15 +142,15 @@ class TestDurableAIAgentParameterFlow:
assert kwargs["run_request"].response_format == ResponseFormatModel
class TestDurableAIAgentProtocolCompliance:
"""Test that DurableAIAgent implements AgentProtocol correctly."""
class TestDurableAISupportsAgentRunCompliance:
"""Test that DurableAIAgent implements SupportsAgentRun correctly."""
def test_agent_implements_protocol(self, test_agent: DurableAIAgent[Any]) -> None:
"""Verify DurableAIAgent implements AgentProtocol."""
assert isinstance(test_agent, AgentProtocol)
"""Verify DurableAIAgent implements SupportsAgentRun."""
assert isinstance(test_agent, SupportsAgentRun)
def test_agent_has_required_properties(self, test_agent: DurableAIAgent[Any]) -> None:
"""Verify DurableAIAgent has all required AgentProtocol properties."""
"""Verify DurableAIAgent has all required SupportsAgentRun properties."""
assert hasattr(test_agent, "id")
assert hasattr(test_agent, "name")
assert hasattr(test_agent, "display_name")