Skip to content

feat(messaging): proactive agent messaging via send_message MCP tool (#321) - #358

Merged
vybe merged 3 commits into
mainfrom
feature/321-proactive-messaging
Apr 16, 2026
Merged

feat(messaging): proactive agent messaging via send_message MCP tool (#321)#358
vybe merged 3 commits into
mainfrom
feature/321-proactive-messaging

Conversation

@vybe

@vybe vybe commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Enables agents to send proactive messages to specific users by verified email across Telegram, Slack, and web channels.

  • Explicit opt-in consent: Users must enable allow_proactive flag on their agent_sharing record
  • Redis-based rate limiting: 10 messages per recipient per hour (survives restarts)
  • Mandatory audit logging: All proactive sends are logged via platform_audit_service
  • Multi-channel delivery: Auto-selection tries telegram → slack → web

Changes

Backend (Python):

  • src/backend/services/proactive_message_service.py — New service with channel adapters
  • src/backend/routers/messages.pyPOST /api/agents/{name}/messages endpoint
  • src/backend/db/agent_settings/sharing.pycan_agent_message_email(), set_allow_proactive()
  • src/backend/db/migrations.pyallow_proactive column migration
  • src/backend/db/telegram_channels.py — Reverse lookup by verified email
  • src/backend/services/slack_service.pyget_user_by_email() for DM delivery

MCP Server (TypeScript):

  • src/mcp-server/src/tools/messages.ts — New send_message MCP tool
  • src/mcp-server/src/client.tssendUserMessage() API method
  • src/mcp-server/src/server.ts — Tool registration

Tests:

  • tests/test_proactive_messaging.py — 18 test cases covering validation, auth, channels

Test Plan

  • Backend tests pass: cd tests && pytest test_proactive_messaging.py -v
  • Manual test: Share agent with email, enable allow_proactive, send message via MCP
  • Verify rate limiting: Send 11 messages, confirm 11th is rejected
  • Verify audit log: Check audit_log table for proactive_message events

Closes #321

🤖 Generated with Claude Code

vybe and others added 3 commits April 16, 2026 15:51
…321)

Enables agents to send proactive messages to specific users by verified
email across Telegram, Slack, and web channels.

Key features:
- Explicit opt-in consent via allow_proactive flag on agent_sharing
- Redis-based rate limiting (10 messages/recipient/hour)
- Mandatory audit logging for all proactive sends
- New send_message MCP tool for agent-to-user outreach
- Channel resolution: telegram -> slack -> web (auto mode)

Backend changes:
- New ProactiveMessageService with delivery adapters
- Messages router with POST /api/agents/{name}/messages
- allow_proactive column + migration on agent_sharing
- Telegram reverse lookup by verified email
- Slack get_user_by_email for DM delivery

MCP Server changes:
- New send_message tool with Zod validation
- TrinityClient.sendUserMessage() method

Closes #321

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Documents the proactive agent messaging feature:
- Architecture diagram showing message flow
- API endpoints (send, update flag, list shares)
- MCP tool usage
- Database schema changes
- Security considerations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add documentation for new components introduced in PR #358:
- messages.py router in Public Access & Monetization section
- proactive_message_service.py in Integrations section
- messages.ts MCP tool module (send_message tool)
- Update tool count from 66 to 67 across 15 modules

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vybe
vybe merged commit f8c5864 into main Apr 16, 2026
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.

feat: proactive agent messaging to channel users (Telegram / Slack / web)

1 participant