Skip to content

fix(swarm): deliver leader messages to in-process teammates - #337

Open
glitch-ux wants to merge 1 commit into
HKUDS:mainfrom
glitch-ux:fix/in-process-teammate-mailbox-key
Open

fix(swarm): deliver leader messages to in-process teammates#337
glitch-ux wants to merge 1 commit into
HKUDS:mainfrom
glitch-ux:fix/in-process-teammate-mailbox-key

Conversation

@glitch-ux

Copy link
Copy Markdown
Contributor

Issue: #336

Problem

For teammates on the in-process backend, messages the leader sends never reach
the teammate — the write and read sides key the mailbox directory differently.

Mailboxes live at ~/.openharness/teams/<team>/agents/<agent_id>/inbox/.

  • InProcessBackend.send_message(agent_id="name@team", ...) writes to the inbox
    keyed by the bare agent nameagents/<name>/inbox/
    (src/openharness/swarm/in_process.py:525). This is the convention used
    everywhere else in the swarm (write_to_mailbox(recipient_name, ...),
    permission_sync's worker_id / leader_id="leader", and the "leader"
    idle-notification target at in_process.py:284), and it is pinned by the
    existing test_send_message_writes_to_mailbox.
  • start_in_process_teammate polls the inbox keyed by the fully-qualified
    name@team id — agents/<name@team>/inbox/
    (src/openharness/swarm/in_process.py:245).

agents/<name>/inbox/agents/<name@team>/inbox/, so the teammate polls a
directory the leader never writes to. Both user_message and mailbox-based
shutdown deliveries are silently dropped.

Change

  • Poll the inbox keyed by config.name (the bare agent name) so the read side
    matches the write side and the rest of the swarm.
  • Add test_teammate_receives_message_sent_by_leader, which drives one real
    teammate query turn (stubbing run_query to yield a single event) and
    asserts the leader's message is drained and marked read from the inbox. It
    fails on main (message stays read=False) and passes with this change.

One-line runtime change; no public API change.

Verification

uv run pytest tests/test_swarm/ -q      # 138 passed (137 before + the new test)
uv run pytest -q                        # only the 2 pre-existing, unrelated
                                        # skill-registry failures remain

The new test fails without the fix and passes with it.

InProcessBackend.send_message writes to the teammate's inbox keyed by the
bare agent name (agents/<name>/inbox), but start_in_process_teammate polled
the inbox keyed by the fully-qualified 'name@team' id. The two paths never
matched, so every leader -> teammate message (user_message and mailbox-based
shutdown) was silently dropped for in-process teammates.

Poll the inbox keyed by config.name so it matches where send_message and the
rest of the swarm (write_to_mailbox, the 'leader' idle-notification target)
deliver. Add a regression test that drives a real teammate query turn and
asserts the leader's message is consumed from the inbox.
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.

1 participant