Skip to content

feat(j5): delegate_task runs a persona on another J5 machine (#957) - #1255

Merged
Jacksondr5 merged 23 commits into
j5/mainfrom
j5code/957-remote-persona-delegate
Nov 27, 2026
Merged

Jacksondr5 merged 23 commits into
j5/mainfrom
j5code/957-remote-persona-delegate

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Problem

delegate_task with a persona could only run here: it refused any target. The agent-tool rulings of 2026-11-06/07 let a persona be delegated to another J5 machine, resolved from that machine's own library against its own models. Jackson added on 2026-11-24 that the machine must be peered.

Closes #957.

What changed

The design is §3, "Smallest build for #957", of the v0.1.11 re-check.

  • Caller (J5-owned agentDelegation.ts):
    • What a persona may name: only target.environmentId, plus projectId. Provider, model, options, driverKind and runtimeMode are still refused, and so is a local environmentId with a projectId.
    • What it refuses for another machine:
      • allow_once;
      • a machine this server isn't peered with. Only J5 machines peer, and a plain T3 Code machine would silently run a plain delegate instead.
      • a peered machine that doesn't advertise the new personaDelegate peer capability (an older J5), naming it and saying "update J5 there".
    • What it sends: the pick's facts, via agentPersona.delegated: who picked it (turnPickSource), the caller's access and sandbox (resolveCallerAccess), and its authors' models (resolveReviewAuthors). The call is wrapped in UnreachableCalls.observe.
  • Carried through upstream's remote delegation: RemoteDelegation.ts gains one input field and one spread into t3_thread_launch's arguments (new FORK.md case 132).
  • Target:
    • Upstream's launch path (case 111): t3_thread_launch gains an optional agentPersona. The handler honours it only from a link session with delegatedFrom, sets its level from clientModeCeiling, and skips the advertised-model check for it. ThreadLaunchService passes the services it already holds and leaves a persona out of the D42 plain-delegate check.
    • The pick is J5's resolveAgentPersonaLaunch / pickDelegatedPersona:
      • an agent's pick is held to the narrower of the caller's access and the link's level, with the caller's sandbox;
      • a person's pick runs as saved only within the link's level narrowed by the asking thread's modes;
      • a real block says "blocked on that machine";
      • a persona that machine lacks is told as that.
  • Model-facing text: delegate_task's description gains "To run the persona on a peered J5 machine, pass only target.environmentId." The persona field gains a matching clause. The tool list grows to 102234 bytes (case 110).

Personas across machines

When a person types @persona:ID on machine A, the persona that runs is the one with that id as saved on the target machine. It runs as saved only within the link's level and the asking thread's own modes; one broader is refused, naming the level. This is the same rule as #956's j5_spawn_agent, after Jackson's decision of 2026-11-27.

Live testing

PASS at 7a88354e53 (tester-web). Two J5 test servers linked at Full access with messages, Haiku only, with a persona b-scout saved on both machines and different instructions on each.

  • Passed:
    • B's persona ran: a mode: "wait" delegation from A ran B's b-scout. It replied B-SCOUT, while the A-SCOUT copy stayed local. The file write was verified on B, and the result came back to A with delegate lineage.
    • Refusals: all five held with no child on B: unpeered, allow_once, target.model, runtimeMode, and a local environmentId with a projectId.
    • Caps: an agent's pick from a Supervised caller was refused with "blocked on that machine". A person's typed @persona in a Supervised thread was refused too, since its Full access is broader than the thread's mode.
    • Restart: a restart at rest and B's thread rendering both passed.
  • Not run as briefed: target: { environmentId } alone. Upstream's remote delegation matches the project there by repository and refused with target_required, because the rig's servers have separate disposable repositories. The test passed target.projectId explicitly instead, which is supported. That's upstream's rule, and agent-tools.md now says it.
  • Since 7a88354e53:
The delegated b-scout on machine B replying B-SCOUT, with lineage back to the thread on Local

Reviews

  • Fable (security lead): clean at 934bfe75fe, after the version-check should-fix. The capability flag and the text-only commits since were reviewed or need no re-check.
  • Opus: clean, after the "blocked on that machine" wording fix and the docs line.

Evals

The evals evals/README.md names for delegate_task's text: evals/j5-cli at 69ca50c543, 3 samples per case, head (#957) against base (#956).

  • No regression:
    • Claude Sonnet 5.5: 213/220 on head against 213/221 on base. One case, j5-thread-send-to-named-top-level-thread, dipped. In a 6-sample tie-break it came to base 6/9 against head 4/9. Every failure on both sides is the same j5_send_message addressing slip, and no sample calls delegate_task.
    • Codex Sol 6.1: 201/218 on head against 204/219 on base. No case dropped by half where base passed.
  • The remote persona works: asked to run @persona:ios-builder or "my iOS Builder persona" on the Mac, both harnesses call delegate_task with persona and only target.environmentId, 6/6 each.
  • Base sends the same call, so the gain is the server now accepting it, not the wording.
  • No misuse: no persona went to another machine uninvited, plain remote delegates stayed plain, and nothing set agentPersona or called t3_thread_launch.
  • Noted, outside this diff: the persona field's description never reaches agents, because Effect drops a description annotated onto a checked schema. The same applies to j5_spawn_agent's fields and upstream's target fields. Tracked as MCP tool field descriptions on checked schemas never reach agents #1254.

Upstream impact

Each upstream-owned file has a minimal J5 edit, recorded in FORK.md in this PR:

  • apps/server/src/peer/RemoteDelegation.ts: new case 132, and a file-table row.
  • apps/server/src/mcp/OrchestratorMcpService.ts: one type line (case 107).
  • apps/server/src/mcp/toolkits/project/tools.ts: one schema field (case 111), with a new file-table row.
  • apps/server/src/mcp/toolkits/project/handlers.ts: the honouring condition, the skip, and the pass-through (case 111).
  • apps/server/src/orchestration-v2/ThreadLaunchService.ts: one option and one condition, inside case 111's seam.

Register D42 records it; Jackson decided on 2026-11-07, 2026-11-24 and 2026-11-27.

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior. Each fails on the code before:
    • agentSubagent.integration.test.ts: the refusals (unpeered, older J5, allow_once, model override) and the peered call's facts;
    • agentPersonaLaunch.integration.test.ts: an agent's pick capped both ways, a person's pick capped by the level, a missing pick refused, a persona the target lacks told as that;
    • RemoteDelegation.test.ts: the carried field and the level set from the link.
  • UI changes: none
  • Live testing: the section above says what ran live and what didn't
  • Upstream-owned files: each recorded in FORK.md (cases 107, 111, 132, with case text and file-table rows)
  • Upstream product: changes to upstream's launch path are recorded under register D42, with Jackson's decisions
  • Surfaces: MCP only. Providers: any, since this is the delegate_task tool. Contracts: J5's OrchestrationV2AgentPersonaRequest and PeerCapabilities. Connection modes: direct and loopback tested; polling not.
  • Docs (Jackson approves): docs/j5/product/a2a/agent-tools.md (the delegate_task paragraph and AC41), docs/j5/product/upstream.md (register D42). FORK.md cases 107, 110, 111 and 132.

Built by Claude Opus 5.5 in Claude Code (J5 Code Crew builder seat).

🤖 Generated with Claude Code

Jacksondr5 and others added 23 commits November 23, 2026 21:29
)

The caller's server calls the other machine's j5_spawn_agent through
PeerMcpClient, after its own checks (Linked environments on, not fenced,
a Full access link, peering, not a Crew member). It scopes the retry key
to the caller and sends the facts the sender header lacks: the spawner's
project, the pick source, its access and sandbox, and its authors' models.
The other machine treats a link session with a sender thread as a third
kind of spawner: the agent is a root, a person's pick is capped at the
link's level, an agent's pick at the narrower of that and the caller's
access, and a block there is lifted there. Both machines record the route
to the other's participant (j5_a2a_peer_route, migration 60) before the
spawn returns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…an import cycle

SpawnAgentService needs J5SpawnAgentResult as a value, and tools.ts imports
SpawnAgentService for its dependency list, so loading SpawnAgentService first
hit tools.ts before SpawnAgentService was initialised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A linked spawner's facts are left out of the request a retry key binds,
  and its persona's retry is exempt from the caller's current modes, as a
  local one is: the spawner's server recomputes both on every call, so a
  retry in a later turn could never finish the first agent (Fable).
- The target refuses a spawner whose server it holds no peering with, so a
  half-removed link can't start an agent that can't reply (Opus).
- The caller's route-record failure names the key to retry with, which was
  lost when the agent gave none (Opus, Fable).
- A link session naming environment_id gets its own refusal text (Opus).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…spawn

# Conflicts:
#	apps/server/src/provider/agentContextBudget.json
…y with (#956)

The spawn may have started there before the line dropped, so the retry the
message asks for must reuse the key, generated or not. agent-tools.md says a
persona's retry is exempt from the caller-mode check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A persona may now name target.environmentId. The caller refuses a machine it
is not peered with (only J5 machines peer; a plain T3 Code machine would run
a plain delegate instead) and allow_once, then sends the pick's facts (who
picked it, the caller's access and sandbox, the authors' models) through
upstream's remote delegation, which carries them to t3_thread_launch there
(new FORK case 131). The target resolves the persona from its own library
against its own models: an agent's pick is held to the narrower of the
caller's access and the link's level with the caller's sandbox, a person's
pick to the link's level narrowed by the delegating thread's modes, and a
block there says it is blocked on that machine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…level, refused otherwise (#957)

The live test showed a Full access persona from a Supervised thread is
refused, not narrowed: a persona never runs below its policy. The docs and the
refusal now say so, naming the thread's mode beside the link. The docs also
say a persona delegate, as any delegate there, needs target.projectId when
upstream can't match the project by repository.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#956)

Only a real block is lifted on that machine; a persona its library doesn't
have, or a library it can't read, gets its own next step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ocked there (#957)

Only a real block is lifted on that machine; a persona its library doesn't
have, or a library it can't read, gets its own next step. The docs say both
machines must run a release with this change, since an older J5 machine runs
a plain delegate in the persona's place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
)

A server advertises the spawn peer capability; spawnOnPeer refuses a machine
that doesn't, since an older J5 there would take the spawner for an outside
agent that can't be replied to.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aming it (#957)

A server advertises the personaDelegate peer capability; the caller refuses a
machine that doesn't, since an older J5 there would drop the persona and run
a plain delegate in its place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…spawn

# Conflicts:
#	apps/server/src/provider/agentContextBudget.json
…mote-persona-delegate

#1244's FORK case landed as 131, so #957's case is now 132; its references
move with it. The tool list measures 102234 bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y key (#956)

The target can fail after creating the agent, naming its own derived key,
which the caller can't pass. agent-tools.md names t3_project_list's
environmentId correctly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…thread's modes (#956)

Jackson's decision of 2026-11-27 (option b): for a person's pick the caller
now sends its thread's own modes as the mode limit, in place of full access,
so the other machine refuses a persona broader than the link or the thread
it is asked from, as #957's delegate_task does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…code/957-remote-persona-delegate

# Conflicts:
#	docs/j5/product/upstream.md
…persona-delegate

# Conflicts:
#	FORK.md
#	apps/server/src/j5/a2a/PeerHttp.test.ts
#	apps/server/src/j5/a2a/PeerStoreService.test.ts
#	apps/server/src/j5/a2a/peerProtocol.ts
#	apps/server/src/provider/agentContextBudget.json
#	docs/j5/product/upstream.md
#	packages/contracts/src/j5.ts
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Nov 27, 2026 5:01pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5037d6e and b0ef555.

Files selected for processing: 21

  • FORK.md
  • apps/server/src/j5/a2a/PeerHttp.test.ts
  • apps/server/src/j5/a2a/PeerStoreService.test.ts
  • apps/server/src/j5/a2a/mcp/orchestratorSurface.test.ts
  • apps/server/src/j5/a2a/peerProtocol.ts
  • apps/server/src/j5/agents/agentDelegation.ts
  • apps/server/src/j5/agents/agentPersonaLaunch.integration.test.ts
  • apps/server/src/j5/agents/agentPersonaOrchestration.ts
  • apps/server/src/j5/agents/agentPersonaPick.ts
  • apps/server/src/j5/agents/agentSubagent.integration.test.ts
  • apps/server/src/mcp/OrchestratorMcpService.ts
  • apps/server/src/mcp/toolkits/project/handlers.ts
  • apps/server/src/mcp/toolkits/project/tools.ts
  • apps/server/src/orchestration-v2/ThreadLaunchService.ts
  • apps/server/src/peer/RemoteDelegation.test.ts
  • apps/server/src/peer/RemoteDelegation.ts
  • apps/server/src/provider/agentContextBudget.json
  • docs/j5/product/a2a/agent-tools.md
  • docs/j5/product/upstream.md
  • packages/contracts/src/j5.ts
  • packages/contracts/src/j5/agentPersona.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 effective changed lines (test files excluded in mixed PRs). labels Nov 27, 2026
@Jacksondr5
Jacksondr5 merged commit 685bd48 into j5/main Nov 27, 2026
40 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/957-remote-persona-delegate branch November 27, 2026 18:38

This branch was successfully deployed

1 active deployment
Preview — b0ef5551 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delegate a persona to another J5 machine

1 participant