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.