-
Notifications
You must be signed in to change notification settings - Fork 0
Add logging for all tool calls #22
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
Add logging for all tool calls #22
Conversation
Implemented a logging wrapper system that automatically logs all tool calls with: - Tool name and parameters when called - Tool result when completed - Error information if tool fails This approach uses a decorator wrapper to add logging to all tools without requiring changes to individual tool implementations. The wrapper is applied via a custom tool decorator that wraps agent.tool registration. Benefits: - Centralized logging configuration - No modifications needed to existing tools - Consistent log format across all tools - Easy to maintain and extend
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.
Pull request overview
This PR implements a centralized logging wrapper system for all tool calls in the meshbot application. The approach uses a decorator pattern to automatically log tool invocations, results, and errors without requiring manual logging code in individual tool implementations. The logging provides consistent formatting with emojis and truncation for readability.
Key changes:
- New
logging_wrapper.pymodule with decorator functions that wrap tool calls with automatic logging - Updated all tool registration functions to use the logging decorator instead of
@agent.tooldirectly - Removed manual logging statements from individual tool functions
- Minor code formatting improvements in
storage.pyandmain.py
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/meshbot/tools/logging_wrapper.py | New module providing with_tool_logging decorator and create_logging_tool_decorator factory function |
| src/meshbot/tools/weather.py | Replaced @agent.tool with @tool() decorator and removed manual logging statements |
| src/meshbot/tools/utility.py | Applied logging wrapper to all 4 utility tools and removed manual logging |
| src/meshbot/tools/query.py | Applied logging wrapper to all query tools |
| src/meshbot/tools/fun.py | Applied logging wrapper to all fun tools |
| src/meshbot/tools/conversation.py | Applied logging wrapper to all conversation tools and removed manual logging |
| src/meshbot/storage.py | Code formatting improvements (line length compliance) |
| src/meshbot/main.py | Code formatting improvements (line length compliance) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| truncated_params[k] = v | ||
| params_str = f" with {truncated_params}" | ||
|
|
||
| logger.info(f"🔧 TOOL CALL: {tool_name}(){params_str}") |
Copilot
AI
Nov 23, 2025
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.
[nitpick] The logging format uses emoji symbols (🔧, ✅, ❌) which may not display correctly in all logging environments or terminals. Consider using plain text prefixes like '[TOOL_CALL]', '[TOOL_RESULT]', '[TOOL_ERROR]' for better compatibility, or make the emoji usage configurable.
| # Extract meaningful parameters (skip ctx and self) | ||
| params_str = "" | ||
| if kwargs: | ||
| # Filter out context and other internal params | ||
| display_params = { | ||
| k: v | ||
| for k, v in kwargs.items() | ||
| if k not in ["ctx", "self"] and not k.startswith("_") | ||
| } |
Copilot
AI
Nov 23, 2025
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.
The logging wrapper only extracts parameters from kwargs but ignores positional args. In the tools being wrapped, parameters are passed as keyword arguments, but if tools were called with positional arguments, those would not be logged. Consider also processing args or documenting that tools must use keyword arguments only.
Implemented a logging wrapper system that automatically logs all tool calls with:
This approach uses a decorator wrapper to add logging to all tools without requiring changes to individual tool implementations. The wrapper is applied via a custom tool decorator that wraps agent.tool registration.
Benefits: