-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: message integration #3269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: message integration #3269
Changes from 9 commits
aab6b6d
df97a67
543c1c3
4565b65
b48c164
e5e769b
28d21f0
bac72c3
a7756f4
d8ca1c5
29bc538
f9dccf6
9752b07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,8 +283,26 @@ def register_functions( | |
|
|
||
| # Check if this function should be enhanced | ||
| if function_names is None or func.__name__ in function_names: | ||
| enhanced_func = self._add_messaging_to_tool(func) | ||
| enhanced_tools.append(FunctionTool(enhanced_func)) | ||
| # If func is a bound toolkit method, route to register_toolkits | ||
| if hasattr(func, '__self__') and isinstance( | ||
| func.__self__, BaseToolkit | ||
| ): | ||
| toolkit_instance = func.__self__ | ||
| method_name = func.__name__ | ||
|
|
||
| # Enhance the specific method on the toolkit instance | ||
| enhanced_toolkit = self.register_toolkits( | ||
| toolkit_instance, tool_names=[method_name] | ||
| ) | ||
|
||
|
|
||
| # Fetch the enhanced method back | ||
| enhanced_method = getattr(enhanced_toolkit, method_name) | ||
|
|
||
| enhanced_tools.append(FunctionTool(enhanced_method)) | ||
| else: | ||
| # Standalone function: add messaging wrapper directly | ||
| enhanced_func = self._add_messaging_to_tool(func) | ||
| enhanced_tools.append(FunctionTool(enhanced_func)) | ||
| else: | ||
| # Return as FunctionTool regardless of input type | ||
| if isinstance(item, FunctionTool): | ||
|
|
@@ -300,6 +318,12 @@ def _add_messaging_to_tool(self, func: Callable) -> Callable: | |
| This internal method modifies the function signature and docstring | ||
| to include optional messaging parameters that trigger status updates. | ||
| """ | ||
| if getattr(func, "__message_integration_enhanced__", False): | ||
| logger.debug( | ||
| f"Function {func.__name__} already enhanced, skipping" | ||
| ) | ||
| return func | ||
|
|
||
| # Get the original signature | ||
| original_sig = inspect.signature(func) | ||
|
|
||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems we didn't consider the case that the toolkit already been enhanced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed