Skip to content

feat(bridge): an agent's calls to another computer are marked, and that computer treats them more strictly than a person's - #1235

Merged
bvsr365 merged 10 commits into
masterfrom
agent-calls-marked-across-computers
Nov 15, 2026
Merged

bvsr365 merged 10 commits into
masterfrom
agent-calls-marked-across-computers

Conversation

@bvsr365

@bvsr365 bvsr365 commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The only way an agent reaches another computer today is a remote subagent, and the other computer (the owner) records every call it makes as a person's: source gui, "Always" rules apply, a /skill in the text runs, and the mode goes up to the device limit. The agent threads design (#1161, §4.3) needs those calls marked as an agent's, so the owner can hold them to an agent's rules. Three later PRs (thread_create with computer, thread tools on qualified ids, runs.wait) build on this one.

Change

  • The key. agent: { thread, run, title, hops, mode } on seven routed rows: threads.create, threads.setModel, threads.setPermissionMode, orchestrator.send, orchestrator.steer, queue.enqueue and orchestrator.abort, each at a new version. It is not droppable, so a caller never sends it to an owner that predates it (computer_outdated). Field names avoid …Id, so the id rewriting leaves them alone. Any change to the key's shape or meaning bumps all seven rows (written beside ROUTED_AGENT_KEY).

  • Who may set it. Only the daemon's own service. ThreadRouter refuses it from a window. A phone's threads.create takes exact keys, and the backend refuses the key outright.

  • The owner handles a marked call as an agent's (remoteAgent.ts). The calling computer comes from the authenticated link, its name from the owner's pairing record. The call runs through the paths thread_send and thread_steer use, with a remote actor (AgentActor.remote) that carries the sender's mode and hops, so nothing is looked up from a local run (which would fall back to the profile default). A marked call:

    • runs with source mcp (no "Always" rules, no person_turn);
    • runs in the narrowest of the carried mode, the device limit and, for a message into an existing thread, the thread's own mode;
    • has text that is never read for /skill or workflow commands;
    • is refused while a question or approval waits (questions_pending);
    • cannot steer a run looser than its sender (ceiling_exceeded);
    • gets an envelope the owner builds with the same builder as on one computer (agentMessage with { computer }): the title cut to 80 characters, control, direction and zero-width characters removed, the computer's name in place of a thread id, both markers defused in title and body, the body capped at 16,000 characters, and origin.body set so the Agent bubble shows only the agent's words;
    • writes sentFrom on the thread, the run (run.sent_from) and a queued item, so blocking the device removes the agent's work;
    • writes its audit row with actor agent (new bridge_audit.actor column).
  • Stored sender. origin.from { node, thread, run, title } with origin.threadId unset. A rule in routedIds.ts beside qualifyStartedFrom leaves from unchanged on every computer. The durable queue keeps from and body across a restart. The Agent bubble's header shows such a sender's title without a link, since its thread is on the other computer.

  • Threads such an agent starts record startedFrom.agent { thread, title, mode } and are held to the narrowed mode from the same write that records them. createdByThreadId stays unset. A marked threads.setPermissionMode above that mode is refused (agent_mode_above_thread). Such a thread cannot start subagents on a third computer (the existing remote_from_remote rule, now tested through a marked create).

  • Limits. A marked message has the same queue caps and repeat check as any agent's message (feat(threads): thread_read is bounded and reads on; agent messages are capped per sender #1222): three waiting per sender and ten in all (agent_queue_full_per_sender, agent_queue_full), and the same text from the same sender within two minutes refused (duplicate_message). A sender on another computer counts as its computer and thread (origin.from), so one computer and two follow one rule and one set of codes; there is no second cap or repeat check. The owner adds limits of its own, each with its own code:

    • hops: the larger of the carried count and the owner's count from the thread's latest run (agent_hops_exceeded);
    • 20 messages per device and thread in 10 minutes (agent_rate_limited);
    • 200 agent-started runs per device per day (agent_daily_budget).

    The rate limit and the budget are counted from the audit, so a restart does not reset them. A follow-up from the agent that started the thread adds none of the owner's own count, as a follow-up to a subagent does on one computer.

  • Agent reach (net_node_policy.agent_reach: none, launched by default, or all) decides which threads a device's agents may change, from the owner's own startedFrom at each call. A marked Stop ends only runs an agent of that device started, and leaves a thread a person took over. Storage and enforcement only; no setting in the app.

  • Remote subagents send the key when every marked row on the far computer is at the version that added it, and stay unmarked on an older computer. A subagent keeps the form of its first call for good (remote_subagents.marked, run database migration 19, after feat(subagents): a subagent on another computer runs within the limit that computer set, with no fixed Auto-accept edits cap #1220's 18), because the owner's replay ledger is keyed by method.

  • Docs. threat-model.md ("Calls marked as an agent's") and SPEC §15.1 state the rules. They also say that the mark is a policy for honest callers, not a boundary.

How to review

Read the commits in order:

  1. feat(bridge): seven routed calls take an agent mark…: the table (routed.ts), the version record and the window refusal. Low risk.

  2. feat(bridge): the owner handles a call marked as an agent's…: the core.

    • remoteAgent.ts decides everything about a marked call.
    • OwnerRoutes.run strips the mark and hands the call over.
    • OrchestratorService gets three small entry points (sendForRemoteAgent, steerForRemoteAgent, stopForRemoteAgent); senderMode, agentEnvelope and agentOriginOf honour actor.remote.

    The risk is in what thread_send's path does with a sender that has no local run. Check withAgentHops, senderMode, and that botSenderOf is skipped for a remote actor.

  3. style(net): formatting only.

  4. feat(subagents): the calling side and its migration.

  5. Tests, then docs.

Verification

Tier 5 (daemon protocol, permissions, security). Tested commit: fa352d287b7e8898b8ddf1240a03ef5fbbafcbf4, rebased on origin/master 73cf19a (after #1220, #1222, #1223, #1224, #1161). The 30 named test files below pass on it (549 tests), and tsc --noEmit is clean for tsconfig.node.json and tsconfig.web.json. Master has since gained #1246 (registerGuiIpc.ts and a GUI test only), which merges without conflict.

  • npx vitest run tests/net/bridge/routed/agentMark.test.ts runs two real daemons over Bridge, with only the turn stood in for. It checks:
    • a marked create: the narrowed mode, startedFrom.agent, no createdByThreadId, and no remote subagent from that thread;
    • a send: source mcp, origin.from without threadId, the owner-built envelope with a defused marker and an unread /review, the mode narrowed to the carried mode and the device limit, run.sent_from, thread sentFrom, an audit row with actor agent, and a replay with the same request id giving one run;
    • a queued message: its origin and sentFrom, the origin after a restart's read of queue.json, a person's edit taking it over, and the drain running it as the agent's;
    • the owner's hop count, and a carried count over the limit;
    • agent reach (launched, none), a malformed mark, a window and a phone refused;
    • questions_pending for a send and a steer, ceiling_exceeded, agent_mode_above_thread, agent_message_too_long and duplicate_message (another sender on the same computer may say the same);
    • feat(threads): thread_read is bounded and reads on; agent messages are capped per sender #1222's per-sender cap for a sender on another computer: a fourth queued message from one sender is agent_queue_full_per_sender, while another thread on that computer is another sender;
    • a marked Stop leaving a person's run;
    • blocking the device removing a marked queued message.
  • tests/run/remoteSubagents.test.ts: every changing call is marked where the far computer knows the mark; an older computer's subagent stays unmarked for good, even after that computer is updated; the existing scenarios pass unchanged against an older computer.
  • tests/net/bridge/routed/remoteSubagents.test.ts (two daemons): a subagent between two current computers is marked (source mcp, startedFrom.agent), and Full access crosses once the owner allows it (feat(subagents): a subagent on another computer runs within the limit that computer set, with no fixed Auto-accept edits cap #1220's rule, no fixed cap).
  • tests/net/bridge/routed/remoteAgentEnvelope.test.ts (title cleaning, the envelope and its body lengths, the mark parser as tables), ids.test.ts (origin.from and startedFrom.agent left as written), table.test.ts (exactly seven marked rows, each new at the row's version, never droppable; routedVersions.json regenerated, no security column changed), tests/net/store/nodePolicyMigration.test.ts (the agent_reach column on an old database, restart, unknown values).
  • Also run: agentMessageBubble, queuedMessagesInChat, threadTitleText, threadMessageQueue, mcpToolRegistry, delegationGuidance and the thread-tool daemon tests (feat(threads): thread_read is bounded and reads on; agent messages are capped per sender #1222's limits, feat(chat): a message an agent sent shows as a labelled "Agent" bubble with only its words #1223's envelope and bubble).
  • npm run test:unit (on the earlier base 46d0114, not repeated after this rebase): 1454 files passed, 18 failed.
    • Three were this change's own tests asserting the old versions or a person's call. They are fixed and pass: routed/remoteSubagents, threadSettingsRevision, and contractVersions (the run database contract is now 19).
    • Four also fail on a clean origin/master here: botWatchers, cliLaunch, platformProductionComposition, profiler.
    • The other 11 pass when run alone on this branch and on master. They failed only under the full suite's load.
  • npx tsc --noEmit -p tsconfig.node.json: clean.
  • Not checked: two real computers on different versions (the older-computer path is covered by the fake owner in remoteSubagents.test.ts and by RoutedClient's existing refusal of unknown keys); the process lane; a real provider turn (turns are stood in for).

Notes

  • Needs review by the other teammate before merging. This changes permission and protocol rules, which the team policy lists as sensitive.
  • Where this differs from the design:
    • No read access ceiling is written for a thread an agent on another computer started. Agents can read and manage any thread; the agent access setting is gone #1197 removed agent access levels on purpose and ignores Thread.accessCeiling.
    • Every marked call obeys the hop limit, so a parent already at the limit cannot start a remote subagent on a computer that knows the mark.
    • The run database contract moves from 18 to 19 (remote_subagents.marked).
  • Overlaps:

Refs #1160

🤖 Generated with Claude Code

bvsr365 and others added 9 commits November 15, 2026 21:16
… computer's daemon sets

The key agent { thread, run, title, hops, mode } is new on threads.create, threads.setModel,
threads.setPermissionMode, orchestrator.send, orchestrator.steer, queue.enqueue and
orchestrator.abort, each at a new version. It is not droppable, so a caller refuses to send it to
an owner that predates it. A window that names it is refused by the router.

Refs #1160

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt's, never as a person's

A marked call runs through a remote agent actor carried in AgentActor.remote: source mcp, the
narrowest of the carried mode and the device limit (and the thread's own), an envelope the owner
builds with the sender's cleaned title and the computer's name from its own pairing record,
refused while a question or approval waits, a steer into a looser run refused, sentFrom on the
thread, run and queued item, and an audit row with actor agent. The owner keeps its own limits:
hop count, a per-thread rate limit, a refused identical repeat and a daily run budget per device.
Agent reach per device (net_node_policy.agent_reach, default launched) decides which threads a
device's agents may change. A thread such an agent starts records startedFrom.agent and is held to
the narrowed mode from its first write; origin.from replaces origin.threadId for such a sender.

Refs #1160

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uter knows the mark, and keeps its first form

A remote subagent's create, model, mode, send and Stop calls carry the agent mark when every row
that has it is at the version that added it on the far computer. A computer from before the mark
gets them unmarked, as before. The form is decided by the subagent's first call and kept on its
rows (remote_subagents.marked, migration 18), since the far computer's replay ledger is keyed by
method and a switch could send a task twice.

Refs #1160

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e and agent reach storage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gent's may do, and that it is a policy, not a boundary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… recorded as an uncertain outcome

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…database contract 18

The two-daemon remote subagent test now expects the owner to take the task as an agent's (source
mcp, startedFrom.agent). The settings revision test reads the version that added ifRevision rather
than assuming it is the row's newest. The run database contract moves to 18 for remote_subagents.marked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…; run database contract 19

The owner's envelope for an agent on another computer is agentMessage with { computer }, so the
bubble shows only the agent's words for such a message too. Migration 19 (remote_subagents.marked)
follows #1220's 18. The Full access remote subagent test's stand-in returns the run's sequence, as a
real send does, and checks the marked thread is held to Full access, not capped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bvsr365
bvsr365 force-pushed the agent-calls-marked-across-computers branch from 88d224d to 531adb2 Compare November 15, 2026 15:49
…nd repeat check every agent has

#1222's caps (three waiting per sender, ten in all) and its repeat check (duplicate_message) count
a sender on another computer by its computer and thread (origin.from), so one computer and two
follow one rule and one set of codes. The owner path's own repeat check is gone; its rate limit and
daily budget stay.

Refs #1160

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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