Skip to content

Commit 2d7f2a1

Browse files
committed
store reference
1 parent 509ddda commit 2d7f2a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/agents/tool.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ class FunctionTool:
179179
and returns whether the tool is enabled. You can use this to dynamically enable/disable a tool
180180
based on your context/state."""
181181

182+
func: ToolFunction[...] | None = None
183+
"""The function that implements the tool. Ensures that a reference to the original function exists
184+
when @function_tool is used."""
185+
182186
# Tool-specific guardrails
183187
tool_input_guardrails: list[ToolInputGuardrail[Any]] | None = None
184188
"""Optional list of input guardrails to run before invoking this tool."""
@@ -661,6 +665,7 @@ async def _on_invoke_tool(ctx: ToolContext[Any], input: str) -> Any:
661665
on_invoke_tool=_on_invoke_tool,
662666
strict_json_schema=strict_mode,
663667
is_enabled=is_enabled,
668+
func=func
664669
)
665670

666671
# If func is actually a callable, we were used as @function_tool with no parentheses

0 commit comments

Comments
 (0)