Skip to content

fix(bot-mode): scope Bot Chat session lookup to the target profile's home - #105323

Closed
yoyodine-industries wants to merge 4 commits into
NousResearch:mainfrom
yoyodine-industries:fix/bot-dm-scope-session-to-profile-home
Closed

yoyodine-industries wants to merge 4 commits into
NousResearch:mainfrom
yoyodine-industries:fix/bot-dm-scope-session-to-profile-home

Conversation

@yoyodine-industries

@yoyodine-industries yoyodine-industries commented Sep 7, 2026 •

Copy link
Copy Markdown

Problem

message_agent delivery runs hermes -p <profile> chat --in '~' -c 'Bot Chat'. tools/bot_relay.py hard-coded the turn args as:

BOT_CHAT_TURN_ARGS = ("chat", "--in", "~", "-c", "Bot Chat", "--create-if-missing", "-Q")

--in ~ scopes the session lookup to the shared home directory, which for a named profile resolves to the default profile's workspace. When the default profile's Bot Chat session is held "live" by the desktop surface, delivery fails with already has a live owner, surfaced to the sender as target_busy — breaking DMs to any bot on the install (coder, majordomo, …).

Fix

Scope the -c "Bot Chat" lookup to the target profile's own home:

  • tools/bot_mode_probe.py: add profile_home_dir(root, name) — root for "default", else root/profiles/<name> (inverse of the existing _hermes_root/_profile_name pair).
  • tools/bot_relay.py: replace the constant BOT_CHAT_TURN_ARGS with _bot_chat_turn_args(profile, root), which builds the profile-scoped argv, and route local_delivery_command through it.
  • tools/bot_mode_dm.py: message_agent_tool now passes _bot_chat_turn_args(resolved, root) into the delivery argv.

Test

  • test_local_delivery_scopes_in_to_profile_home: asserts --in resolves to root/profiles/<profile> (and to root for the default profile).
  • test_local_delivery_command_and_ack updated to the profile-scoped --in.

Both proven red on base, green with the fix.

scripts/run_tests.sh tests/tools/test_bot_relay_windows_paths.py tests/tools/test_bot_mode_dm.py tests/tools/test_bot_turn_lock.py

Related Issue

Fixes #105460

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run scripts/run_tests.sh tests/tools/test_bot_relay_windows_paths.py tests/tools/test_bot_mode_dm.py tests/tools/test_bot_turn_lock.py and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation — or N/A (internal bug fix; no user-facing behavior change, in-code docstrings updated)
  • I've updated cli-config.yaml.example — or N/A (no config keys added or changed)
  • I've updated CONTRIBUTING.md or AGENTS.md — or N/A (no contribution/agent-instruction change)
  • I've considered cross-platform impact (Windows, macOS) — or N/A (Path-based; Windows path test covers it)
  • I've updated tool descriptions/schemas — or N/A (message_agent tool interface unchanged)

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets area/profiles Multi-profile isolation, HERMES_HOME scoping sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Sep 7, 2026
@teknium1

teknium1 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Post-merge scope check: leaving this PR open, not treating it as superseded. #105442 (5280fe99872a58f1b9d25b00a79d240ecd035f7d) pins the target profile home for advertised live-owner ingress, but does not change BOT_CHAT_TURN_ARGS or the relay/local CLI --in ~ behavior addressed here. That working-directory/session-lookup proposal needs its own premise and behavior review; fixing live-owner admission alone does not establish that it is implemented or unnecessary. Thanks @yoyodine-industries for isolating the target-profile lookup concern.

@yoyodine-industries
yoyodine-industries force-pushed the fix/bot-dm-scope-session-to-profile-home branch from d1d6ef4 to bc167fb Compare September 9, 2026 00:04
@yoyodine-industries

Copy link
Copy Markdown
Author

Ready for review — scopes Bot Chat session lookup to the target profile's home. Mergeable on current main; CI needs a maintainer to approve-and-run. Thanks!

@yoyodine-industries

Copy link
Copy Markdown
Author

Merged current main in to clear the conflict — upstream reworked the relay sender plumbing in the meantime, so a plain rebase wasn't clean. Kept both sides: upstream's author=author and our _bot_chat_turn_args(resolved, root) scoping of the Bot Chat lookup to the target profile's home. Run: tests/tools/test_bot_mode_dm.py + tests/tools/test_bot_relay_windows_paths.py -> 55 passed, 1 skipped. Mergeable again.

…home

message_agent delivery ran 'hermes -p <profile> chat --in ~ -c Bot Chat', and '--in ~' scoped the session lookup to the shared home directory, which for a named profile resolves to the DEFAULT profile's workspace. If the default profile's Bot Chat was held live by the desktop surface, delivery failed with 'already has a live owner' and surfaced as target_busy — affecting DMs to any bot on the install.

Resolve --in to the target profile's own home (root for 'default', else root/profiles/<name>) via a new profile_home_dir() helper in bot_mode_probe; bot_relay gains _bot_chat_turn_args(profile, root) that builds the scoped argv, and bot_mode_dm uses it.
@yoyodine-industries
yoyodine-industries force-pushed the fix/bot-dm-scope-session-to-profile-home branch from 3b69f58 to 12dbbe1 Compare September 13, 2026 03:15
…ssion-to-profile-home

Union resolution in tools/bot_mode_dm.py: the branch's _bot_chat_turn_args(profile, root)
scoping is kept, upstream's _hermes_cli() is taken. Upstream's side of the hunk imported
BOT_CHAT_TURN_ARGS, which this branch replaced with the scoped helper, so taking it verbatim
would have been an ImportError.

tools/bot_relay.py auto-merged coherently: _bot_chat_turn_args() still scopes --in to the
target profile's own home and upstream's new local_delivery_command() now routes through it;
no other module builds a --in argv.

One upstream test (test_delivery_pins_the_hermes_entrypoint_beside_this_interpreter, the
entrypoint-pinning regression) asserted the OLD argv with --in ~ and so encoded the bug this
branch fixes. Its expectation now names the profile home, matching the branch's scoping tests.

Verified: scripts/run_tests.sh tests/tools/test_bot_mode_dm.py tests/tools/test_bot_relay_windows_paths.py
tests/tools/test_bot_mode_probe.py -> 75 passed, 1 skipped (windows-only).
@yoyodine-industries

Copy link
Copy Markdown
Author

Closing as superseded, per your note on #105460: main's live-owner delivery path (5280fe99872a58f1b9d25b00a79d240ecd035f7d and follow-ups) already queues a DM into a bot whose Bot Chat is open in Desktop rather than refusing it, and the -c "Bot Chat" lookup resolves against the -p profile's own state.db — so the --in ~ premise behind this patch was wrong and the change isn't needed. Thanks for the precise scope check.

For the record: we're running v0.21.3 and have seen no target_busy refusal since; if one recurs we'll reopen or file fresh with a receipt, as you asked.

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

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(bot-mode): bot DM delivery resolves to the default profile's session, not the target bot's

3 participants