(
self,
tool_name: str,
arguments: Dict[str, Any],
config: FunctionToolConfig,
tool_context: Dict[str, Any] | None = None,
)
| 239 | return specs |
| 240 | |
| 241 | def _execute_function_tool( |
| 242 | self, |
| 243 | tool_name: str, |
| 244 | arguments: Dict[str, Any], |
| 245 | config: FunctionToolConfig, |
| 246 | tool_context: Dict[str, Any] | None = None, |
| 247 | ) -> Any: |
| 248 | mgr = self._get_function_manager() |
| 249 | if config.auto_load: |
| 250 | mgr.load_functions() |
| 251 | func = mgr.get_function(tool_name) |
| 252 | if func is None: |
| 253 | raise ValueError(f"Tool {tool_name} not found in {self._functions_dir}") |
| 254 | |
| 255 | call_args = dict(arguments or {}) |
| 256 | if ( |
| 257 | tool_context is not None |
| 258 | # and "_context" not in call_args |
| 259 | and self._function_accepts_context(func) |
| 260 | ): |
| 261 | call_args["_context"] = tool_context |
| 262 | return func(**call_args) |
| 263 | |
| 264 | def _function_accepts_context(self, func: Any) -> bool: |
| 265 | try: |
no test coverage detected