99from .usage import Usage
1010
1111if TYPE_CHECKING :
12- from .agent import AgentBase
1312 from .items import TResponseInputItem
1413 from .run_context import _ApprovalRecord
1514
@@ -45,9 +44,6 @@ class ToolContext(RunContextWrapper[TContext]):
4544 tool_call : ResponseFunctionToolCall | None = None
4645 """The tool call object associated with this invocation."""
4746
48- agent : AgentBase [Any ] | None = None
49- """The active agent for this tool call, when available."""
50-
5147 def __init__ (
5248 self ,
5349 context : TContext ,
@@ -56,7 +52,6 @@ def __init__(
5652 tool_call_id : str | object = _MISSING ,
5753 tool_arguments : str | object = _MISSING ,
5854 tool_call : ResponseFunctionToolCall | None = None ,
59- agent : AgentBase [Any ] | None = None ,
6055 * ,
6156 turn_input : list [TResponseInputItem ] | None = None ,
6257 _approvals : dict [str , _ApprovalRecord ] | None = None ,
@@ -85,15 +80,13 @@ def __init__(
8580 else cast (str , tool_call_id )
8681 )
8782 self .tool_call = tool_call
88- self .agent = agent
8983
9084 @classmethod
9185 def from_agent_context (
9286 cls ,
9387 context : RunContextWrapper [TContext ],
9488 tool_call_id : str ,
9589 tool_call : ResponseFunctionToolCall | None = None ,
96- agent : AgentBase [Any ] | None = None ,
9790 ) -> ToolContext :
9891 """
9992 Create a ToolContext from a RunContextWrapper.
@@ -106,16 +99,12 @@ def from_agent_context(
10699 tool_args = (
107100 tool_call .arguments if tool_call is not None else _assert_must_pass_tool_arguments ()
108101 )
109- tool_agent = agent
110- if tool_agent is None and isinstance (context , ToolContext ):
111- tool_agent = context .agent
112102
113103 tool_context = cls (
114104 tool_name = tool_name ,
115105 tool_call_id = tool_call_id ,
116106 tool_arguments = tool_args ,
117107 tool_call = tool_call ,
118- agent = tool_agent ,
119108 ** base_values ,
120109 )
121110 return tool_context
0 commit comments