Overview
Messaging tools let agents communicate with users immediately through the active channel, without waiting for the full agent loop to finish. Useful for subagents, long-running tasks, and progress updates.Tools
send_message
Send a text message to the user immediately via the configured channel.Message text to send to the user
Target channel (telegram, discord, slack). Omit to use the current session’s channel.
Target chat/channel ID on the platform. Required when channel is specified.
send_file
Send a file to the user as an attachment. Provide the absolute path to an existing file.Absolute path to the file to send
Optional caption or description for the file
Target channel (telegram, discord, slack). Omit to use the current session’s channel.
Target chat/channel ID on the platform. Required when channel is specified.
Channel Behavior
Telegram
- Messages: Sent as regular text messages with Markdown formatting support
- Files: Images sent as photos, others as document attachments
- Captions: Displayed below images/documents
Discord
- Messages: Sent as regular messages with Discord Markdown support
- Files: Uploaded as attachments with optional captions
- Captions: Displayed as message text above the attachment
Slack
- Messages: Posted to the workspace/channel
- Files: Uploaded with optional comments
- Captions: Displayed as file comments
CLI Mode
When running in CLI mode (no active channel):- Messages: Logged to console with
[Agent Message]prefix - Files: File path logged with
[Agent File]prefix - Returns: “Message logged (no active channel)” or “File ready (no active channel)“
Use Cases
Progress Updates
Subagent Communication
Subagents usesend_message to report results back to the user:
Multi-Channel Delivery
Send the same result to multiple channels:Callback System
The messaging tools delegate actual sending to callbacks registered at construction:Error Handling
File Not Found
Callback Failure
Invalid Session Key
Best Practices
- Use send_message for progress updates to keep users informed
- Use send_file instead of telling users to check local folders
- Add captions to files for context
- Check file exists before sending (or handle errors gracefully)
- Target specific channels only when needed (defaults to current session)
Implementation
Defined ingrip/tools/message.py. Uses:
- Async callback system for channel integration
inspect.iscoroutinefunction()to handle sync/async callbacks- Session key format:
channel:chat_idfor cross-channel delivery - Graceful fallback to logging when no callback is set