mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-16 03:14:45 +08:00
fix(agents): patch _run in ToolInterceptor to ensure interrupt triggering (#753)
Fixes #752 * fix(agents): patch _run in ToolInterceptor to ensure interrupt triggering * Update the code with review comments
This commit is contained in:
@@ -159,6 +159,13 @@ class ToolInterceptor:
|
||||
# Use object.__setattr__ to bypass Pydantic validation
|
||||
logger.debug(f"Attaching intercepted function to tool '{safe_tool_name}'")
|
||||
object.__setattr__(tool, "func", intercepted_func)
|
||||
|
||||
# Also ensure the tool's _run method is updated if it exists
|
||||
if hasattr(tool, '_run'):
|
||||
logger.debug(f"Also wrapping _run method for tool '{safe_tool_name}'")
|
||||
# Wrap _run to ensure interception is applied regardless of invocation method
|
||||
object.__setattr__(tool, "_run", intercepted_func)
|
||||
|
||||
return tool
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user