Skip to content

The agent that grows with you

fix(desktop): @ picker lists a remote default by its title, qualifies colliding tags, and completes cross-connection bots cold

teknium10ff5ec84787a
diff --git a/apps/desktop/src/plugins/hermes-bots/data.ts b/apps/desktop/src/plugins/hermes-bots/data.ts
index e73d45cee91..8b5ff31e212 100644
--- a/apps/desktop/src/plugins/hermes-bots/data.ts
+++ b/apps/desktop/src/plugins/hermes-bots/data.ts
@@ -628,6 +628,10 @@ interface UnionAgentRow {
connectionLabel?: string
handle?: string
profile?: string
+ /** Credential-free metadata Electron enumerates alongside the name — the
+ * only source of a REMOTE row's title, since profiles.list is asked of the
+ * active gateway alone. */
+ profileMetadata?: Pick<RosterRow, 'display_name' | 'has_avatar' | 'title' | 'ui_meta'>
targetProfile?: string
}
@@ -639,91 +643,96 @@ interface UnionRoster {
sources?: GatewaySource[]
}
-export function useRoster() {
- const activeConnectionId = useValue(host.state.connectionId)
+/** One roster snapshot for `activeConnectionId` — the pane's query and the
+ * composer's cold-cache prime (`primeRoster`) share it, so both see the same
+ * cross-connection rows. */
+async function fetchRosterSnapshot(activeConnectionId: null | string | undefined): Promise<RosterSnapshot> {
+ // Stamp the ISSUE time on the snapshot: mergeServerMeta compares it
+ // against each bot's last local meta write, and a fetch issued before
+ // a write can only carry pre-write ui_meta. (Issue time is the
+ // conservative bound — the server answered no earlier than this.)
+ const issuedAt = Date.now()
+
+ // Rich rows (last_session, canonical_session, ui_meta, has_avatar)
+ // come from the ACTIVE gateway's profiles.list — the canonical Bot
+ // Chat is resolved server-side by NAME (the "Bot Chat" registry row),
+ // so the roster never sends session pointers.
+ // Refresh the alias identity index alongside the roster: alias routes
+ // (Desktop profile → remote backend root) are what let a backend row
+ // keep its configured friendly identity after activation (#89131).
+ // Best-effort and feature-detected — a failed read keeps the last
+ // good index rather than dropping identities mid-session.
+ if (typeof host.profileRoutes === 'function') {
+ const epoch = beginAliasRouteIndex()
- return useQuery({
- queryKey: [...ROSTER_KEY, activeConnectionId],
- queryFn: async () => {
- // Stamp the ISSUE time on the snapshot: mergeServerMeta compares it
- // against each bot's last local meta write, and a fetch issued before
- // a write can only carry pre-write ui_meta. (Issue time is the
- // conservative bound — the server answered no earlier than this.)
- const issuedAt = Date.now()
-
- // Rich rows (last_session, canonical_session, ui_meta, has_avatar)
- // come from the ACTIVE gateway's profiles.list — the canonical Bot
- // Chat is resolved server-side by NAME (the "Bot Chat" registry row),
- // so the roster never sends session pointers.
- // Refresh the alias identity index alongside the roster: alias routes
- // (Desktop profile → remote backend root) are what let a backend row
- // keep its configured friendly identity after activation (#89131).
- // Best-effort and feature-detected — a failed read keeps the last
- // good index rather than dropping identities mid-session.
- if (typeof host.profileRoutes === 'function') {
- const epoch = beginAliasRouteIndex()
+ try {
+ indexAliasRoutes(await host.profileRoutes(), epoch)
+ } catch {
+ /* keep the previous alias index */
+ }
+ }
- try {
- indexAliasRoutes(await host.profileRoutes(), epoch)
- } catch {
- /* keep the previous alias index */
- }
- }
+ // Owner routing is ambient in the SDK now (post-#92731): requestForBot
+ // resolves the active owner itself, no captured route needed here.
+ const activeBot = {
+ name: String(host.state.profile?.get?.() || 'default').trim() || 'default'
+ }
- // Owner routing is ambient in the SDK now (post-#92731): requestForBot
- // resolves the active owner itself, no captured route needed here.
- const activeBot = {
- name: String(host.state.profile?.get?.() || 'default').trim() || 'default'
- }
+ const local = await requestForBot<RosterSnapshot>(activeBot, 'profiles.list', {})
+ // Newer backends inject the teammate-messaging protocol into every
+ // session's system prompt (agent.bot_mode_protocol) — SOUL.md must not
+ // carry a second copy. Older gateways lack the flag: keep appending.
+ serverInjectsProtocol = Boolean(local?.bot_mode_protocol)
+
+ // Multi-source desktops (hermes-agent #86875) also expose the union
+ // agent roster across every registered connection. Merge agents from
+ // OTHER sources in as additional rows. Feature-detected + best-effort:
+ // an older Desktop build (no host.agents) or a roster hiccup leaves
+ // the local list exactly as it was.
+ if (typeof host.agents === 'function') {
+ try {
+ const union = await host.agents()
+ const previous: RosterRow[] = $lastRoster.get().filter(row => !row?.ghost)
+ const merged = mergeMultiSourceRoster(local, union, activeConnectionId, previous)
+ const sources = Array.isArray(union?.sources) ? union.sources : []
- const local = await requestForBot<RosterSnapshot>(activeBot, 'profiles.list', {})
- // Newer backends inject the teammate-messaging protocol into every
- // session's system prompt (agent.bot_mode_protocol) — SOUL.md must not
- // carry a second copy. Older gateways lack the flag: keep appending.
- serverInjectsProtocol = Boolean(local?.bot_mode_protocol)
-
- // Multi-source desktops (hermes-agent #86875) also expose the union
- // agent roster across every registered connection. Merge agents from
- // OTHER sources in as additional rows. Feature-detected + best-effort:
- // an older Desktop build (no host.agents) or a roster hiccup leaves
- // the local list exactly as it was.
- if (typeof host.agents === 'function') {
- try {
- const union = await host.agents()
- const previous: RosterRow[] = $lastRoster.get().filter(row => !row?.ghost)
- const merged = mergeMultiSourceRoster(local, union, activeConnectionId, previous)
- const sources = Array.isArray(union?.sources) ? union.sources : []
-
- return {
- ...merged,
- profiles: (merged?.profiles || []).map(row => annotateBotSource(row, sources)),
- sources,
- fetchedAt: issuedAt
- }
- } catch {
- /* Aggregate-roster failure, not a registry change: keep the
- * previously painted remote rows on the roster as unreachable
- * instead of repainting Bot Mode local-only (#98844). `sources`
- * stays absent so the pane falls back to its remembered source
- * snapshot rather than clearing it. */
- const previous: RosterRow[] = $lastRoster.get().filter(row => !row?.ghost)
- const merged = mergeMultiSourceRoster(local, null, activeConnectionId, previous)
-
- return {
- ...merged,
- profiles: (merged?.profiles || []).map(row =>
- row?.remoteSource ? { ...row, sourceReachable: false } : row
- ),
- fetchedAt: issuedAt
- }
- }
+ return {
+ ...merged,
+ profiles: (merged?.profiles || []).map(row => annotateBotSource(row, sources)),
+ sources,
+ fetchedAt: issuedAt
}
+ } catch {
+ /* Aggregate-roster failure, not a registry change: keep the
+ * previously painted remote rows on the roster as unreachable
+ * instead of repainting Bot Mode local-only (#98844). `sources`
+ * stays absent so the pane falls back to its remembered source
+ * snapshot rather than clearing it. */
+ const previous: RosterRow[] = $lastRoster.get().filter(row => !row?.ghost)
+ const merged = mergeMultiSourceRoster(local, null, activeConnectionId, previous)
return {
- ...(local && typeof local === 'object' ? local : {}),
+ ...merged,
+ profiles: (merged?.profiles || []).map(row =>
+ row?.remoteSource ? { ...row, sourceReachable: false } : row
+ ),
fetchedAt: issuedAt
}
- },
+ }
+ }
+
+ return {
+ ...(local && typeof local === 'object' ? local : {}),
+ fetchedAt: issuedAt
+ }
+}
+
+export function useRoster() {
+ const activeConnectionId = useValue(host.state.connectionId)
+
+ return useQuery({
+ queryKey: [...ROSTER_KEY, activeConnectionId],
+ queryFn: () => fetchRosterSnapshot(activeConnectionId),
refetchInterval: 5000,
staleTime: 5000,
retry: ROSTER_QUERY_RETRY,
@@ -731,6 +740,26 @@ export function useRoster() {
})
}
+/** Fill the live connection's roster cache entry without mounting the Bots
+ * pane. `useRoster` is the only `host.agents()` caller and the pane its only
+ * mount, so a launch that never opened it left the composer's synchronous
+ * readers blind to every other connection; the middleware's fallback asked
+ * the ACTIVE gateway for profiles.list, which cannot enumerate them (#94018).
+ * One fetch, no polling — the pane owns the refresh while open. Never throws. */
+export async function primeRoster(): Promise<void> {
+ const connectionId = String(host.state.connectionId?.get?.() || host.activeConnectionId?.() || 'local')
+
+ try {
+ await queryClient.fetchQuery({
+ queryKey: [...ROSTER_KEY, connectionId],
+ queryFn: () => fetchRosterSnapshot(connectionId),
+ staleTime: 5000
+ })
+ } catch {
+ /* offline or older build — readers keep their existing fallbacks */
+ }
+}
+
/** Synchronous union-roster read for the composer surfaces (autocomplete
* provider + mention middleware). useRoster caches under
* [...ROSTER_KEY, activeConnectionId] — a 3-element key — so a bare
@@ -905,6 +934,10 @@ function mergeMultiSourceRoster(
profiles.push({
name: profile,
+ // A remote row's title/display_name ride the union enumeration; without
+ // them a remote default titled "CoS Bot" only ever tags as @hermes(-device)
+ // and its title slug is unknown to the composer (#103731).
+ ...(agent.profileMetadata || {}),
handle: agent.handle,
connectionId,
connectionKind: agent.connectionKind,
@@ -1145,6 +1178,7 @@ export function resolveRosterMentions(
.replace(/`[^`\n]*`/g, ' ')
const byForm = new Map<string, RosterRow | null>()
+ const formsByBot = new Map<RosterRow, Set<string>>()
for (const bot of members) {
if (!bot?.name || isActiveRosterBot(bot, active)) {
@@ -1168,6 +1202,8 @@ export function resolveRosterMentions(
}
}
+ formsByBot.set(bot, forms)
+
for (const form of forms) {
if (!form) {
continue
@@ -1209,14 +1245,22 @@ export function resolveRosterMentions(
const mentioned: RosterRow[] = []
const seen = new Set<string>()
- for (const match of prose.matchAll(/(^|\s)@([a-z0-9][a-z0-9_-]*)/gi)) {
+ // `@tag@connection` is the form the picker inserts when a bare tag is
+ // ambiguous (two remote defaults both titled "CoS Bot"): the suffix pins
+ // the row to one connection, so a colliding tag still resolves exactly.
+ for (const match of prose.matchAll(/(^|\s)@([a-z0-9][a-z0-9_-]*)(?:@([a-z0-9][a-z0-9_-]*))?/gi)) {
let token = match[2].toLowerCase()
+ const connection = (match[3] || '').toLowerCase()
if (token === 'hermes') {
token = byForm.has('hermes') ? 'hermes' : token
}
- const bot = byForm.get(token)
+ const bot = connection
+ ? [...formsByBot].find(
+ ([row, forms]) => String(row.connectionId || '').toLowerCase() === connection && forms.has(token)
+ )?.[0]
+ : byForm.get(token)
if (!bot) {
continue
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts b/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
index bc05ef64336..c6456fa2767 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
@@ -68,6 +68,10 @@ const { cache, hostMock, live } = vi.hoisted(() => {
notify: vi.fn(),
request: vi.fn(async () => ({})),
requestProfile: vi.fn(async () => ({})),
+ agents: vi.fn(async (): Promise<{ agents: Array<Record<string, unknown>>; sources: Array<Record<string, unknown>> }> => ({
+ agents: [],
+ sources: []
+ })),
state: {
connectionId: { get: () => 'local', listen: () => () => undefined },
focusedSessionProfile: { get: () => live.focused, listen: () => () => undefined },
@@ -97,6 +101,12 @@ vi.mock('@hermes/plugin-sdk', async () => {
[...cache.values()]
.filter(entry => queryKey.every((part, index) => entry.key[index] === part))
.map(entry => [entry.key, entry.value]),
+ fetchQuery: async ({ queryFn, queryKey }: { queryFn: () => Promise<unknown>; queryKey: unknown[] }) => {
+ const value = await queryFn()
+ cache.set(keyOf(queryKey), { key: queryKey, value })
+
+ return value
+ },
getQueryData: (key: unknown[]) => cache.get(keyOf(key))?.value,
invalidateQueries: () => undefined,
setQueryData: (key: unknown[], value: unknown) => cache.set(keyOf(key), { key, value })
@@ -123,7 +133,7 @@ interface Fixture {
cacheKeyConnection?: string
/** Profile owning the chat on screen; a bot never @s itself. */
focused?: string
- profiles?: Array<Record<string, unknown>>
+ profiles?: Array<Record<string, unknown>> | null
}
/** Register the plugin and hand back its composer contributions. */
@@ -135,11 +145,16 @@ async function contributions({
vi.resetModules()
cache.clear()
live.focused = focused
- // Exactly where useRoster writes it: suffixed with the connection id.
- cache.set(JSON.stringify(['hermes-bots', 'roster', cacheKeyConnection]), {
- key: ['hermes-bots', 'roster', cacheKeyConnection],
- value: { profiles }
- })
+
+ // Exactly where useRoster writes it: suffixed with the connection id. A
+ // null `profiles` leaves the cache COLD, as a launch that never mounted the
+ // Bots pane does.
+ if (profiles) {
+ cache.set(JSON.stringify(['hermes-bots', 'roster', cacheKeyConnection]), {
+ key: ['hermes-bots', 'roster', cacheKeyConnection],
+ value: { profiles }
+ })
+ }
const plugin = (await import('./plugin')).default
const registered: Contribution[] = []
@@ -288,6 +303,62 @@ describe('@-mention completions', () => {
expect(provide('default-v')[0]).toMatchObject({ insert: '@default-vera', meta: expect.stringContaining('Vera') })
expect(provide('zzz')).toEqual([])
})
+
+ /** Local default plus two remote defaults, each titled on its own host
+ * (#103731). Order-flipped so a Map-last-wins slip in the resolver or the
+ * picker would surface as a retargeted local @hermes. */
+ const REMOTE_DEFAULTS: Array<Record<string, unknown>> = [
+ {
+ connectionId: 'vps',
+ connectionLabel: 'VPS',
+ handle: 'default-vps',
+ name: 'default',
+ remoteSource: true,
+ sourceScoped: true,
+ ui_meta: { 'hermes-bots': { title: 'CoS Bot' } }
+ },
+ {
+ connectionId: 'wsl',
+ connectionLabel: 'WSL',
+ handle: 'default-wsl',
+ name: 'default',
+ remoteSource: true,
+ sourceScoped: true,
+ ui_meta: { 'hermes-bots': { title: 'CoS Bot' } }
+ }
+ ]
+
+ it.each([
+ { label: 'local first', profiles: [{ name: 'default' }, { name: 'researcher' }, ...REMOTE_DEFAULTS] },
+ { label: 'remotes first', profiles: [...REMOTE_DEFAULTS].reverse().concat([{ name: 'researcher' }, { name: 'default' }]) }
+ ])('lists titled remote defaults under their slug, qualified on collision, and keeps @hermes local ($label)', async ({ profiles }) => {
+ const { handler, provide } = await contributions({ focused: 'researcher', profiles })
+ const inserts = provide('').map(item => item.insert)
+
+ // Both remote defaults tag as "CoS Bot" — the bare slug names neither, so
+ // the picker pins each to its connection; the local default stays @hermes.
+ expect(inserts).toEqual(expect.arrayContaining(['@hermes', '@cos-bot@vps', '@cos-bot@wsl']))
+ expect(inserts).not.toContain('@cos-bot')
+ expect(inserts.filter(insert => insert === '@hermes')).toHaveLength(1)
+
+ const qualified = await handler({ text: 'ask @cos-bot@wsl for the plan' })
+ expect(qualified.text).toMatch(/message_agent target: "default@wsl"/)
+ expect(qualified.text).not.toMatch(/default@vps/)
+
+ // A bare @hermes is this machine's default in either roster order.
+ const local = await handler({ text: '@hermes summarize' })
+ expect(local.text).toMatch(/@hermes = agent profile "default"/)
+ expect(local.text).not.toMatch(/message_agent target: "default@/)
+ })
+
+ it('offers a uniquely titled remote default under its title slug', async () => {
+ const { handler, provide } = await contributions({ profiles: [{ name: 'default' }, REMOTE_DEFAULTS[0]] })
+
+ expect(provide('cos').map(item => item.insert)).toEqual(['@cos-bot'])
+
+ const result = await handler({ text: '@cos-bot status?' })
+ expect(result.text).toMatch(/message_agent target: "default@vps"/)
+ })
})
describe('the mention middleware', () => {
@@ -387,6 +458,34 @@ describe('the mention middleware', () => {
expect(result.text).not.toMatch(/`hermes/)
})
+ it('resolves a cross-connection mention cold, before the Bots pane ever mounted (#94018)', async () => {
+ // Nothing in the query cache; the active gateway knows only itself, the
+ // union enumeration (host.agents) knows the remote default and its title.
+ hostMock.requestProfile.mockResolvedValueOnce({ profiles: [{ name: 'default' }] })
+ hostMock.agents.mockResolvedValueOnce({
+ agents: [
+ { connectionId: 'local', connectionKind: 'local', connectionLabel: 'This device', handle: 'default-this-device', profile: 'default' },
+ {
+ connectionId: 'vps',
+ connectionKind: 'remote',
+ connectionLabel: 'VPS',
+ handle: 'default-vps',
+ profile: 'default',
+ profileMetadata: { ui_meta: { 'hermes-bots': { title: 'CoS Bot' } } }
+ }
+ ],
+ sources: [{ connectionId: 'local', kind: 'local' }, { connectionId: 'vps', kind: 'remote' }]
+ })
+
+ const { handler, provide } = await contributions({ profiles: null })
+ const result = await handler({ text: '@cos-bot what is on the calendar?' })
+
+ expect(hostMock.agents).toHaveBeenCalled()
+ expect(result.text).toMatch(/message_agent target: "default@vps"/)
+ // The prime filled the cache: the picker now completes the remote title slug too.
+ expect(provide('cos').map(item => item.insert)).toEqual(['@cos-bot'])
+ })
+
it('ignores an email address', async () => {
const { handler } = await contributions({ focused: 'research', profiles: [{ name: 'research' }, { name: 'ops' }] })
const untouched = 'mail [email protected] and ping @nosuchbot'
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.tsx b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
index ebee3d9c3e2..28721700352 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
@@ -41,6 +41,7 @@ import {
cachedUnionRoster,
isActiveRosterBot,
migrateBotMeta,
+ primeRoster,
resolveRosterMentions
} from './data'
import {
@@ -142,11 +143,18 @@ export default {
connectionId: String(host.state.connectionId?.get?.() || host.activeConnectionId?.() || 'local')
}
- for (const profile of profiles) {
- if (!profile?.name || isActiveRosterBot(profile, live)) {
- continue
- }
+ const offered = profiles.filter(profile => profile?.name && !isActiveRosterBot(profile, live))
+ // Two rows tagging alike (two remote defaults both titled "CoS Bot")
+ // cannot share a bare tag — it would resolve to neither. Pin the
+ // ambiguous ones to their connection (#103731).
+ const tagCounts = new Map<string, number>()
+
+ for (const profile of offered) {
+ const tag = botMentionTag(profile).toLowerCase()
+ tagCounts.set(tag, (tagCounts.get(tag) || 0) + 1)
+ }
+ for (const profile of offered) {
const handle = botHandle(profile.name, profile)
const display = displayName(profile, $botMeta.get()[profile.name])
// Renamed bots complete on their friendly name — the tag is the
@@ -162,10 +170,12 @@ export default {
continue
}
+ const qualified = (tagCounts.get(tag.toLowerCase()) || 0) > 1 && profile.connectionId
+ const insert = qualified ? `@${tag}@${profile.connectionId}` : `@${tag}`
const source = profile.connectionLabel ? ` · ${profile.connectionLabel}` : ''
items.push({
- insert: `@${tag}`,
- display: `@${tag}`,
+ insert,
+ display: insert,
meta: `Bot · ${display}${source}`
})
}
@@ -317,6 +327,18 @@ export default {
const unbindProfileListener = bindProfileSync($focusedBotOwner)
const unbindGatewayListener = host.state.gateway.listen(handleSessionsGatewayTransition)
+ // The composer's @ picker reads the roster cache synchronously; fill it on
+ // the first gateway open so cross-connection bots complete before the Bots
+ // pane has ever mounted (#94018). The pane owns the refresh once open.
+ const primeOnGatewayOpen = (state: unknown) => {
+ if (String(state) === 'open') {
+ void primeRoster()
+ }
+ }
+
+ primeOnGatewayOpen(host.state.gateway.get())
+ const unbindRosterPrime = host.state.gateway.listen(primeOnGatewayOpen)
+
// #93492 root fix: the registry pushes a lifecycle event when a
// connection is removed. The gateway store already disposes the dead
// sockets; the persisted group-chat rosters referencing that connection
@@ -352,6 +374,10 @@ export default {
unbindGatewayListener()
}
+ if (typeof unbindRosterPrime === 'function') {
+ unbindRosterPrime()
+ }
+
if (typeof unbindConnectionsChanged === 'function') {
unbindConnectionsChanged()
}
@@ -729,7 +755,16 @@ export default {
connectionId: String(host.state.connectionId?.get?.() || host.activeConnectionId?.() || 'local')
}
- const cached = cachedUnionRoster()
+ let cached = cachedUnionRoster()
+
+ if (!Array.isArray(cached?.profiles)) {
+ // Cold cache (the Bots pane never ran this launch): fill it the way
+ // the pane does. The profiles.list fallback below only knows the
+ // ACTIVE gateway and drops every cross-connection target (#94018).
+ await primeRoster()
+ cached = cachedUnionRoster()
+ }
+
const roster = Array.isArray(cached?.profiles) ? cached.profiles : null
let mentionedBots = roster ? resolveRosterMentions(text, roster, live) : []
diff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.md
index 62ecc75cbf9..5f890bb0654 100644
--- a/website/docs/user-guide/bot-mode.md
+++ b/website/docs/user-guide/bot-mode.md
@@ -159,6 +159,7 @@ Bots message each other with attribution, and you can hand work off from any cha
- **@mentions** — type `@researcher have a look at this` in any chat and the composer's `@` autocomplete helps you pick the right Bot; on send, the mention is resolved against the live roster and the active Bot is told exactly who you mean (profile, friendly name, and device for cross-connection Bots). The Bot then composes its own message and sends it with `message_agent` — your text is never forwarded verbatim, and the reply comes back attributed to that agent. An email address or an unknown `@` passes through untouched. Bots on other connected machines are reachable the same way: the Desktop relays the message over that connection's own socket (see *Bots across machines* below).
- **Renamed Bots keep their tags in sync** — give a Bot a friendly name (the pencil in its chat header, or `hermes profile rename`) and it becomes taggable by that name: a Bot titled *Research Buddy* answers to `@research-buddy` (and `@researchbuddy`), in regular chats and in group rooms alike. The composer's `@` autocomplete offers the renamed tag and also matches when you type the old profile name, which keeps resolving too. This includes the primary Bot: rename it *Maia* and group-turn prompts introduce it as `@maia`, its inter-agent messages sign as `Message from 🤖 Maia (@hermes)`, and teammates can `message_agent(target="maia")` it — `@hermes` stays a working alias.
+- **Remote Bots complete under their titles, from any chat.** The `@` autocomplete lists Bots on your other connected machines as soon as the Desktop is connected — you do not have to open the Bots pane first — and a remote `default` appears under its Bot Mode title (`@cos-bot` for a remote default titled *CoS Bot*, not a second `@hermes`). When two Bots would tag alike, the picker inserts the connection-qualified form (`@cos-bot@<connection>`), which resolves to exactly that machine's Bot. A relayed message signed `Message from 🤖 hermes (@hermes@<connection>)` still renders as an agent notice, not as your own text.
- **Direct messages** — every Bot Chat carries the `message_agent` tool: a Bot messages a teammate by calling `message_agent(target="researcher", message="…")`. The target is the teammate's profile name, its friendly name (`hermes profile rename` or the Bot Mode title — `Scribe`, `Dr. Foo`) or the `@`-tag the Desktop inserts for it (`@scribe`, `@dr-foo`, `@drfoo`); `@hermes` always means the primary Bot. A profile name is matched first, so it can never be hijacked by another Bot's friendly name, and a friendly name shared by two Bots is refused with the roster instead of guessing. The tool validates the target against the live roster, prefixes the sender's `Message from 🤖 <friendly name> (@<handle>):` attribution automatically, and delivers into the teammate's canonical Bot Chat. Delivery is **fire-and-forget**: the sender gets a *dispatch* acknowledgement (`status: queued` plus a `delivery_id` — and a `process_id` for the background delivery process — means the message was handed to that process, not that it was delivered), finishes its turn, and that process's completion notification carries the outcome — the reply, or the delivery failure. On surfaces that cannot receive completion notifications (an `api_server` session, one-shot runners) the acknowledgement instead carries `reply_delivery: poll`: the sender retrieves the outcome with `process(action="wait", session_id=…)` before ending its turn, and the outcome is also saved into the sender's session transcript as a delivery row when the process exits, so the reply is never silently lost. The notification carries the reply whole up to the message size limit (16,000 characters); a longer one arrives as its tail and says how much was cut (`process(action="log", session_id=…)` has the rest). The message travels as a real parameter (nothing shell-interpreted — quotes, `$(...)`, and backticks arrive verbatim), and the Bot composes its own message rather than forwarding your words. The teammate roster — names **and roles** from each profile's title/description — is part of every Bot Chat's system prompt, so Bots know who does what before choosing a recipient. The tool exists **only** in canonical Bot Chat sessions on Bot-Mode-managed installs; regular chats, group-room member sessions, and CLI sessions never see it.
Local messages also reach a Bot Chat that stays open in Desktop or the TUI. The receiving backend keeps ownership: it reads durable ingress on its existing notification poller, admits immediately when idle, or waits until the running turn and already queued human prompts finish. A `queued` acknowledgement confirms durable admission, **not** a completed reply. The target profile retains the delivery ID and receipt under `runtime/bot_live_delivery/`; `settled` confirms completion. A crashed or cancelled imported turn is not automatically replayed, and pending work pinned to a departed owner remains inspectable rather than being silently rerun. Do not resend a delivery whose outcome is unknown. Older backends without live-delivery capability retain the existing ownership refusal; restart that backend after upgrading.