Skip to content

fix(tools): recognize email addresses as explicit targets in send_message#34748

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/send-message-email-target-explicit
Closed

fix(tools): recognize email addresses as explicit targets in send_message#34748
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/send-message-email-target-explicit

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes send_message email platform routing: valid email addresses like user@example.com are now recognized as explicit targets by _parse_target_ref(), preventing the "No home channel set for email" error when sending proactive emails.

Related Issue

Fixes #34740

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tools/send_message_tool.py: Added _EMAIL_TARGET_RE regex pattern and email platform handler in _parse_target_ref() so email addresses are recognized as explicit targets and routed directly
  • tests/tools/test_send_message_tool.py: Added TestParseTargetRefEmail class with 6 regression tests covering valid emails, edge cases (plus-tags, dots, whitespace), invalid addresses, and cross-platform isolation

How to Test

  1. Run pytest tests/tools/test_send_message_tool.py -k "TestParseTargetRefEmail" -v — all 6 tests should pass
  2. Run pytest tests/tools/test_send_message_tool.py -k "TestParseTargetRef" -v — all 30 existing + new tests should pass (no regressions)
  3. Verify that _parse_target_ref("email", "user@example.com") returns ("user@example.com", None, True) instead of (None, None, False)

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Code Intelligence

  • Analyzed: tools/send_message_tool.py:_parse_target_ref (callers: 3 in send_message_tool.py)
  • Blast radius: LOW — single function, email platform only, no changes to existing platform handlers
  • Related patterns: follows same regex+handler pattern as _E164_TARGET_RE (phone platforms), _WEIXIN_TARGET_RE, _YUANBAO_TARGET_RE

…sage

When using send_message with the email platform, valid email addresses
like user@example.com were not recognized as explicit targets by
_parse_target_ref(). This caused the function to return (None, None,
False), forcing the system into channel-name resolution which has no
way to resolve a raw email address, resulting in 'No home channel set
for email' errors.

Add _EMAIL_TARGET_RE pattern and email platform handler in
_parse_target_ref() so email addresses are treated as explicit targets
and routed directly without requiring a home target configuration.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets platform/email Email (IMAP/SMTP) adapter labels May 29, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #35258. Your commit was cherry-picked onto current main with your authorship preserved in git log (commit d3724c0), plus a small follow-up fixing the no-home-channel error to point at EMAIL_HOME_ADDRESS instead of EMAIL_HOME_CHANNEL. Thanks for the clean fix and tests.

@teknium1 teknium1 closed this May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists platform/email Email (IMAP/SMTP) adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: send_message does not recognize explicit email targets and incorrectly falls back to home target resolution

3 participants