Skip to content

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

@Credo76

Description

@Credo76

Bug Description

🐛 Bug Report: send_message_tool.py misses explicit target parsing for email platform

Describe the bug

When using send_message with the email platform, a valid email address is not recognized as an explicit target.

As a result, send_message incorrectly falls back to the email home target resolution instead of sending directly to the resolved address. This causes proactive email sends to fail even when the target has already been resolved to a valid email address.

Note: Inbound email handling and reply flows appear to work normally, so this issue is specific to the proactive send_message(...) path.


Environment / Observed On

  • Hermes Agent Version: v0.15.1 (2026.05.29)

Reproduction Steps & Example Behavior

  1. Alias Resolution (Works):
    resolve_channel_name('email', 'ChouWeiping') -> returns 'weiping0201@icloud.com'
  2. Target Parsing (Fails):
    _parse_target_ref('email', 'weiping0201@icloud.com') -> returns (None, None, False)

Because the parsed result is not treated as explicit, the routing logic falls back to the email home target path and eventually throws an error.

Affected Scenarios:

  • Using Alias:
    send_message(target="email:ChouWeiping", message="test")
    (Fails even though the name resolves to a valid email address.)

  • Using Direct Email Target:
    send_message(target="email:weiping0201@icloud.com", message="test")
    (Also fails because the raw email address isn't recognized as explicit.)


Expected Behavior

A valid email target should be treated as explicit and routed directly, without requiring an email home target to be configured.

For example, after resolution:
_parse_target_ref('email', 'weiping0201@icloud.com')
Should return an explicit target result (is_explicit=True) rather than (None, None, False).

Actual Behavior

Email targets fall through the parser, forcing the system into home target resolution, which fails with the following error:
No home channel set for email to determine where to send the message...


Suspected Root Cause

In tools/send_message_tool.py, the _parse_target_ref(...) method implements platform-specific explicit-target parsing for several platforms (e.g., Slack, Discord, Telegram), but completely lacks an email branch.

Because of this gap, valid email addresses fall through the parser and default to (None, None, False).


Suggested Fix

Treat valid email addresses as explicit targets in _parse_target_ref(...) by adding an email branch:

elif platform == "email":
if "@" in target_ref:
return target_ref, None, True

(The final validation logic may want to be stricter than this, but the primary issue is that explicit email targets currently are not parsed at all.)


Additional Note

There also seems to be a naming inconsistency around the fallback/home-target path between:

  • EMAIL_HOME_CHANNEL
  • EMAIL_HOME_ADDRESS

While this may be a separate issue, it appears secondary here. The primary bug is that explicit email targets are not recognized, which incorrectly forces the fallback path in the first place.

Steps to Reproduce

Steps to Reproduce

  1. Configure Hermes email gateway with working IMAP/SMTP credentials.
  2. Ensure an email contact exists in the channel directory, or use a previously learned contact from an inbound email session.
  3. Confirm the contact name resolves to an email address, e.g.:
    resolve_channel_name('email', 'ContactName') -> returns 'someone@example.com'
  4. Trigger a proactive message using either an alias or a direct email target:
    • send_message(target="email:ContactName", message="test")
    • send_message(target="email:someone@example.com", message="test")
  5. Observe that the resolved email target is not recognized as explicit.
  6. Hermes falls back to the email home target path instead of sending directly to the explicit address.
  7. If no home target is configured, the operation fails with a home-target-related error.

Expected Behavior

Steps to Reproduce

  1. Configure Hermes email gateway with working IMAP/SMTP credentials.
  2. Ensure an email contact exists in the channel directory, or use a previously learned contact from an inbound email session.
  3. Confirm the contact name resolves to an email address, e.g.:
    resolve_channel_name('email', 'ContactName') -> returns 'someone@example.com'
  4. Trigger a proactive message using either an alias or a direct email target:
    • send_message(target="email:ContactName", message="test")
    • send_message(target="email:someone@example.com", message="test")
  5. Observe that the resolved email target is not recognized as explicit.
  6. Hermes falls back to the email home target path instead of sending directly to the explicit address.
  7. If no home target is configured, the operation fails with a home-target-related error.

Actual Behavior

A resolved email target is not recognized as explicit by the proactive send_message path.
For example, a contact name may resolve to a valid email address, but Hermes still falls back to home target resolution instead of sending directly. If no home target is configured, the operation fails with a home-target-related error.

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

No response

Debug Report

Hermes Agent v0.15.1 (2026.5.29)

Reproduced with proactive email sending via send_message(...).
A direct email target such as email:someone@example.com is not treated as explicit and falls back to home target resolution.

Observed:
- _parse_target_ref('email', 'user@example.com') -> (None, None, False)
- email gateway IMAP/SMTP otherwise appeared functional
- inbound/reply flow seemed okay; issue appears specific to proactive send path

Operating System

Ubuntu 24.04 (Linux 7.0.3-1-t2-noble)

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/toolsTool registry, model_tools, toolsetsplatform/emailEmail (IMAP/SMTP) adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions