Skip to content

feat(tool): debug tool usage via channels#1332

Merged
yinwm merged 4 commits intosipeed:mainfrom
afjcjsbx:feat/debug-tool-usage
Mar 19, 2026
Merged

feat(tool): debug tool usage via channels#1332
yinwm merged 4 commits intosipeed:mainfrom
afjcjsbx:feat/debug-tool-usage

Conversation

@afjcjsbx
Copy link
Copy Markdown
Collaborator

📝 Description

This PR introduces the Real-Time Tool Feedback (tool_feedback) feature.

Currently, users have to wait in silence while the agent executes potentially long or multi-step tool calls (like web searches, executing commands, etc.). This feature improves transparency and User Experience (UX) by sending a short, formatted notification directly to the chat channel whenever the agent invokes a tool.

Key changes:

  • Added tool_feedback configuration inside agents.defaults (with enabled and max_args_length properties).
  • Implemented the broadcasting logic in pkg/agent/loop.go to send a 🔧 formatted message to the active channel containing the tool name and a truncated preview of the arguments.
  • Updated config.example.json and added comprehensive documentation in docs/debug.md.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

N/A

📚 Technical Context (Skip for Docs)

  • Reference URL: N/A
  • Reasoning: In production environments or group chats, users cannot see the server's standard output or debug logs. Giving the bot the ability to "think out loud" when using tools prevents users from thinking the bot is frozen during heavy operations (like downloading files or scraping web pages).

🧪 Test Environment

  • Hardware: All
  • OS: All
  • Model/Provider: All
  • Channels: All

📸 Evidence (Optional)

Click to view Logs/Screenshots image

Example of in-chat output:

🔧 `web_search`
{
  "query": "picoclaw release notes"
}

@alexhoshina
Copy link
Copy Markdown
Collaborator

This feature might be blocked by #1316. Perhaps after the agent refactoring, it could be better implemented through the event system.

Copy link
Copy Markdown
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Security Concern: Sensitive Information Exposure

This feature sends tool arguments directly to the chat channel. However, some tools may receive sensitive information in their arguments:

  • exec commands might contain passwords: curl -u user:password ...
  • http_request might include API keys or tokens
  • File operations could expose configuration secrets

Question: How should this be handled? Have you considered:

  1. Tool blacklist (exclude certain tools from sending feedback)
  2. Sensitive field masking (redact fields like password, token, secret, api_key)
  3. User-configurable exclusion rules

Would like to hear your thoughts on this.

@afjcjsbx
Copy link
Copy Markdown
Collaborator Author

hello @yinwm, thanks for the review, I agree with your security concern that sensitive information could be leaked into the channel this way, but wouldn't it be the same if after the agent executed an exec command with sensitive information I asked him to provide me with the command he just used?

@afjcjsbx
Copy link
Copy Markdown
Collaborator Author

yes I just tested it and I confirm that it is, the information is leaked. If you want to replicate it you can create a command.txt file in pico workspace, inside the file you write the command curl -u "USERNAME:PASSWORD" https://api.example.com/resource, ask him to run it and after runned, ask him what command he just ran.

@yinwm
Copy link
Copy Markdown
Collaborator

yinwm commented Mar 18, 2026

hi @afjcjsbx , sorry for late, plz resolve conflicts

@afjcjsbx
Copy link
Copy Markdown
Collaborator Author

no problem @yinwm, thanks! probably with the agent refactor we could configure this logic well with the pre-post hook functionality of the tools

Copy link
Copy Markdown
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Code quality is good, no security issues or critical bugs found.

One minor note: the default value for tool_feedback.enabled differs between defaults.go (true) and config.example.json (false). Consider unifying them for consistency, but this is non-blocking.

Thanks for the contribution!

@yinwm yinwm merged commit 7673b62 into sipeed:main Mar 19, 2026
4 checks passed
tong3jie pushed a commit to tong3jie/picoclaw that referenced this pull request Mar 20, 2026
* feat(tool): debug usage via channel

* set defaults

* fix conflicts
j0904 pushed a commit to j0904/picoclaw that referenced this pull request Mar 22, 2026
* feat(tool): debug usage via channel

* set defaults

* fix conflicts
renato0307 pushed a commit to renato0307/picoclaw that referenced this pull request Mar 26, 2026
* feat(tool): debug usage via channel

* set defaults

* fix conflicts
andressg79 pushed a commit to andressg79/picoclaw that referenced this pull request Mar 30, 2026
* feat(tool): debug usage via channel

* set defaults

* fix conflicts
ra1phdd pushed a commit to ra1phdd/picoclaw-pkg that referenced this pull request Apr 12, 2026
* feat(tool): debug usage via channel

* set defaults

* fix conflicts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: agent domain: config go Pull requests that update go code type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants