Skip to content

Conversation

@jinglemansweep
Copy link
Contributor

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

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
Copilot AI review requested due to automatic review settings November 23, 2025 19:15
@jinglemansweep jinglemansweep merged commit 12ab45b into main Nov 23, 2025
1 check passed
@jinglemansweep jinglemansweep deleted the claude/add-tool-call-logging-018QXAns4tPerfzePxACmwoD branch November 23, 2025 19:16
Copy link

Copilot AI left a 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.py module with decorator functions that wrap tool calls with automatic logging
  • Updated all tool registration functions to use the logging decorator instead of @agent.tool directly
  • Removed manual logging statements from individual tool functions
  • Minor code formatting improvements in storage.py and main.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}")
Copy link

Copilot AI Nov 23, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +37
# 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("_")
}
Copy link

Copilot AI Nov 23, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants