Skip to content

Let the Runner decide which agents run - #1824

Closed
loganj wants to merge 4 commits into
agents-runner-connectionsfrom
agents-runner-runs
Closed

loganj wants to merge 4 commits into
agents-runner-connectionsfrom
agents-runner-runs

Conversation

@loganj

@loganj loganj commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 This is step 6 of the Manager/Runner split for agents. It is an inert refactor.

What changes

Until now the Manager decided which agents run, and the Runner asked it each time: agent(key), ready(key) and running() were Manager answers.

Now AgentsRunner.update(identities, viewer) decides:

  • Runner: it picks the running agents. These are the viewer's agents whose community the Runner is connected to and not disconnected, except agents with an unfinished Delete or Remove. It builds their frozen views from its own records, reconciles the runners, finds the interrupted turns, then resumes and catches up. agent, ready and running are now Runner methods.
  • Manager: its update() asks the Runner to update first, then shows what the Runner decided. It still builds the list the screens show, with its own archiveUnchecked mark and the agents still being deleted. When nothing in the shown list differs from the Runner's view, it reuses the Runner's object, so agents and running share objects as before.

The second commit moves the event questions the runners ask into the Runner too: whether the agent is in the event's channel (member), whether the channel is its DM (dm), a sender's display name and the classifier's context. They read only the Runner's own connections and agent custody.

The third commit lets the Runner keep the memberships it last decided from, so its record changes find a membership themselves (liveMember). It also queues plugin wakes and an agent's own handoff itself.

RunnerManager no longer has ready, agent, running, member, dm, context, displayName, liveMember or handoff.

Ordering

The Runner now resumes and catches up before the Manager notifies its subscribers. Before, it was after. Both steps start async work that reads the Runner's own list, which is already current, so the order does not change what runs.

Presence stays with the Manager in this PR, and it now reads the Runner's running list. Presence moves with the hidden page.

Why

In a hidden agents page, the Runner must know what to run without asking the screens. What it still needs from the Manager for this is the identity list and the viewer, which can cross the agents link (#1748) as a topic.

Tests

  • The fourth commit fixes a flaky test, does not catch up after a restart on a message it already heard live, and the two catch-up tests built the same way. CI failed on it once. Each test read the current second, set up the first copy, and only then froze the clock. When setup crossed into the next second, the copy's connection started one second late. Catch-up then covered the second of the unheard message, so the restarted copy skipped it. The race is on main and on this stack's base too. A trace of the failing run showed the connection's since one second after start. The tests now freeze the clock before setup. Under CPU load, the test failed 2 of 25 runs before the fix and 0 of 25 after.
  • No new tests. Behavior is unchanged, and the service tests cover what runs, interrupted turns, resume and catch-up.
  • The agents and bundled agent-type suites pass. The full vitest run fails only the emoji-picker tests that always fail in this local worktree (4 tests). CI runs the browser journeys.

🤖 Generated with Claude Code

loganj and others added 4 commits October 28, 2026 10:19
AgentsRunner.update now picks the running agents from the identities,
its records and its own community connections, reconciles the runners,
finds the interrupted turns and resumes and catches up. The Manager
shows what it decided and no longer answers the Runner's agent, ready
or running questions. Behavior is unchanged.

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
Whether an agent is in an event's channel, whether the channel is its
DM, a sender's display name and the classifier's context read only the
Runner's connections and agent custody, so they move into AgentsRunner.
RunnerManager loses member, dm, context and displayName. Behavior is
unchanged.

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
The Runner keeps the memberships it last decided from, so its record
changes find the membership without asking the Manager. Plugin wakes
and an agent's own handoff are queued by the Runner too. RunnerManager
loses liveMember and handoff. Behavior is unchanged.

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
Three catch-up tests captured the second, then set up the first copy,
then froze the clock at that second. When setup crossed into the next
second, the copy's connection started a second late, so catch-up read
the second of the unheard message and the restarted copy skipped it.
Freeze the clock before setup instead.

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
@loganj

loganj commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Closing: this change is now part of #1748, which collects one column of the Manager/Runner split in one PR.

@loganj loganj closed this Oct 29, 2026
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