1717from __future__ import annotations
1818
1919import typing
20- from typing import Any
2120from typing import AsyncGenerator
21+ from typing import Sequence
2222
2323from typing_extensions import override
2424
3030from ._base_llm_processor import BaseLlmRequestProcessor
3131
3232if typing .TYPE_CHECKING :
33- from ...agents import BaseAgent
34- from ...agents import LlmAgent
33+ from ...agents . base_agent import BaseAgent
34+ from ...agents . llm_agent import LlmAgent
3535
3636
3737class _AgentTransferLlmRequestProcessor (BaseLlmRequestProcessor ):
@@ -72,8 +72,12 @@ async def run_async(
7272request_processor = _AgentTransferLlmRequestProcessor ()
7373
7474
75- def _build_target_agents_info (target_agent : Any ) -> str :
76- # TODO: Refactor the annotation of the parameters
75+ class _AgentLike (typing .Protocol ):
76+ name : str
77+ description : str
78+
79+
80+ def _build_target_agents_info (target_agent : _AgentLike ) -> str :
7781 return f"""
7882Agent name: { target_agent .name }
7983Agent description: { target_agent .description }
@@ -85,17 +89,16 @@ def _build_target_agents_info(target_agent: Any) -> str:
8589
8690def _build_transfer_instruction_body (
8791 tool_name : str ,
88- target_agents : list [ Any ],
92+ target_agents : Sequence [ _AgentLike ],
8993) -> str :
9094 """Build the core transfer instruction text.
91- TODO: Refactor the annotation of the parameters
9295
9396 This is the agent-tree-agnostic portion of transfer instructions. It
94- works with any objects having ``.name`` and ``.description`` attributes
97+ works with any BaseAgent implementation.
9598
9699 Args:
97100 tool_name: The name of the transfer tool (e.g. 'transfer_to_agent').
98- target_agents: Objects with ``.name`` and ``.description`` .
101+ target_agents: Agents available as transfer targets .
99102
100103 Returns:
101104 Instruction text for the LLM about agent transfers.
@@ -128,8 +131,8 @@ def _build_transfer_instruction_body(
128131
129132def _build_transfer_instructions (
130133 tool_name : str ,
131- agent : ' LlmAgent' ,
132- target_agents : list [ ' BaseAgent' ],
134+ agent : LlmAgent ,
135+ target_agents : Sequence [ BaseAgent ],
133136) -> str :
134137 """Build instructions for agent transfer (agent-tree variant).
135138
0 commit comments