Skip to content

feat(j5): retire j5_stop_agent for t3_thread_interrupt with the Captain's rule - #982

Merged
Jacksondr5 merged 2 commits into
j5/mainfrom
j5code/955-retire-stop-agent
Nov 9, 2026
Merged

Jacksondr5 merged 2 commits into
j5/mainfrom
j5code/955-retire-stop-agent

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Problem

The agent-tool rulings of 2026-11-07 (register D2) retire j5_stop_agent. Since v0.1.7, upstream's t3_thread_interrupt with stop: true is the same full Stop. The only thing J5's tool still added was the Captain's exemption: a Captain may stop its own seats whatever their access. Closes #955.

What changed

  • J5 re-declares t3_thread_interrupt (j5/a2a/mcp/orchestratorSurface.ts, threadInterrupt.ts) with upstream's description, parameters and result as shipped. Its handler adds one rule. When the caller is the Captain of the live Crew seat the target holds, the call stops or interrupts with no mode check and no DispatchModeLimit. Every other caller, outside agents included, gets upstream's own writesThreads declaration and OrchestratorMcpService.interruptThread.
  • Choosing the rule per call needs the Crew store, and declarations can only be built inside upstream's McpToolAccess.ts. So FORK.md case 2 gains eitherBy there: upstream's either, picked by an effect. A call bound for a linked environment takes upstream's check.
  • An agent's Stop says so. Upstream's stop: true passes the reason as given, so a Stop without one reads "Stopped by user" in the timeline (upstream's own comment says agent callers always set one). J5 words it as upstream words an interrupt, "Stopped by an agent", as j5_stop_agent did.
  • j5_stop_agent is gone: the tool, its handler and its tests. t3_thread_interrupt takes its place in the pre-approved tools (j5ToolPreapproval.ts), so a read-only or approval-never Captain can still stop its seats. The j5_stop_crew and Crew-stop refusals now name t3_thread_interrupt with stop: true.
  • Tests: one new case in orchestratorSurface.test.ts. It covers a non-Captain refused on a broader seat, upstream's path within the caller's modes, a Captain stopping a broader seat with no limit (replay included), and a Captain's plain interrupt. The case fails on this branch with the Captain check disabled. The old j5_stop_agent cases in handlers.test.ts and outsideAgent.test.ts are removed, because the outside-agent path is now upstream's unchanged. The env-gated Luna live test stops through upstream's service. agentContextBudget.json shrinks by 772 bytes of tool list.
  • Docs: docs/j5/product/a2a/agent-tools.md already describes this (docs(j5): the agent tools after linked environments #954). FORK.md, the migration runbook, upstream-convergence.md and the A2A README are updated.

Text agents read (for Jackson before merge)

  • t3_thread_interrupt keeps upstream's description, unchanged: "Interrupt a top-level thread's running turn. No runId: newest running turn. No effect when idle. For a delegate, use task_cancel." Upstream's schema doesn't describe stop to the model either; agents see only the parameter name. The live test checks whether models find it.
  • J5's standing instructions (orchestrationInstructions.ts) are unchanged. They never named j5_stop_agent, and their existing clause ("Stop a delegate run you replace or no longer need with task_cancel, never t3_thread_interrupt on a childThreadId") still fits.
  • Refusal text, changed:
    • j5_stop_crew by a non-Captain: "Only a Crew's Captain stops it: message the Captain with j5_send_message, or stop one agent with t3_thread_interrupt and stop: true."
    • Crew stop by a non-Captain (CrewStopService.ts): "Ask the Captain with j5_send_message, or stop one agent with t3_thread_interrupt and stop: true."
  • Migration runbook orientation template: lists t3_thread_interrupt (with stop: true to stop an agent) in place of j5_stop_agent.

Live testing

Pass for the paths exercised, on an isolated test server with real Claude Haiku and GPT Luna turns (tester seat, reports artifacts/test-reports/982/).

  • Discovery (head cd042a907b): told only to stop a peer's work, Haiku and Luna each chose t3_thread_interrupt with stop: true on their own.
  • Captain's rule (head cd042a907b): a Supervised Captain stopped an active Full-access seat. A non-Captain agent in a narrower mode was refused on a broader target.
  • Stop behaviour (head 9761be5f37): Luna stopped an agent with a real queued follow-up. The queue was held (queueHeld: true, the follow-up never started), and Resume ran it. A held turn restarted correctly.
  • Delegates (head 9761be5f37, the review fix): a Supervised Captain stopping a Full-access seat also stopped that seat's live Haiku delegate_task delegate.
  • Head change: between the two heads, only the Captain path's delegated-task stop changed. Discovery and the refusal rule were not re-run on 9761be5f37, because that code didn't change.
  • Not exercised live: delegates running on a linked machine (no second machine in the test setup). The focused test covers that call.
  • Observation, not a regression: stopping an idle seat whose delegate was still running returned interrupt_requested with the seat's already-completed run. That follows upstream's Stop, which reaches the last run while background work is pending, and the delegate did stop.

Upstream impact

  • apps/server/src/mcp/McpToolAccess.ts: adds eitherBy (FORK.md case 2, file-table row already present). Upstream's own tools are unchanged.
  • t3_thread_interrupt is no longer registered from upstream's toolkit (upstreamCatalog.ts). J5 registers its re-declaration, as decided in register D2 (Jackson, 2026-11-07; record).

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior (backend changes ship with focused tests)
  • UI changes: none in this PR
  • Live testing: the section above says what ran live and what did not
  • Upstream-owned files: each one is recorded in FORK.md (case text and file-table row) in this PR
  • Upstream product: the change to upstream's interrupt (the Captain's rule, agent stop wording) is register D2, linked above
  • Surfaces: agents only (MCP). No client, contract or UI change. Codex and Claude both get the tool and its pre-approval; other providers get it as an MCP tool like any other. Remote: a call for a linked environment follows upstream's path.
  • Docs: the agent-tools definition already matched (docs(j5): the agent tools after linked environments #954); FORK.md and the runbook updated

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

🤖 Generated with Claude Code

…in's rule

Agents now stop another agent with upstream's t3_thread_interrupt, whose
stop: true is the full Stop. J5 re-declares it with upstream's description
and parameters and one rule: a Captain stopping a seat of its own Crew skips
upstream's check that the target runs within the caller's modes. Every other
caller, outside agents included, gets upstream's declaration and handler.

An agent's stop: true now records "Stopped by an agent", as j5_stop_agent
did, where upstream's would read as the user's. Crew stop's refusal names the
new tool, and t3_thread_interrupt takes j5_stop_agent's place in the
pre-approved tools.

Closes #955.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 9, 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 9, 2026 4:31am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 22 billable files and costs up to $5.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 9 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 5 included reviews currently available. Your 29 included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 067d732 and 9761be5.

Files selected for processing: 22

  • FORK.md
  • apps/server/src/j5/a2a/CrewStopService.ts
  • apps/server/src/j5/a2a/README.md
  • apps/server/src/j5/a2a/mcp/handlers.test.ts
  • apps/server/src/j5/a2a/mcp/handlers.ts
  • apps/server/src/j5/a2a/mcp/j5ToolPreapproval.test.ts
  • apps/server/src/j5/a2a/mcp/j5ToolPreapproval.ts
  • apps/server/src/j5/a2a/mcp/orchestratorSurface.test.ts
  • apps/server/src/j5/a2a/mcp/orchestratorSurface.ts
  • apps/server/src/j5/a2a/mcp/orchestratorSurfaceHandlers.ts
  • apps/server/src/j5/a2a/mcp/orchestratorVerbs.live.test.ts
  • apps/server/src/j5/a2a/mcp/outsideAgent.test.ts
  • apps/server/src/j5/a2a/mcp/registration.test.ts
  • apps/server/src/j5/a2a/mcp/threadInterrupt.ts
  • apps/server/src/j5/a2a/mcp/tools.test.ts
  • apps/server/src/j5/a2a/mcp/tools.ts
  • apps/server/src/j5/a2a/mcp/upstreamCatalog.ts
  • apps/server/src/j5/a2a/stopThread.ts
  • apps/server/src/mcp/McpToolAccess.ts
  • apps/server/src/provider/agentContextBudget.json
  • docs/j5/product/upstream-convergence.md
  • docs/j5/runbooks/agent-migration.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Nov 9, 2026
thread.stop queues the delegated-task stop only when a delegate has a thread
here. Upstream's handler calls stopDelegatedTasks after it with the same
command, which also ends delegates on a linked machine and retries a failed
stop; the Captain's path now does the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:L 100-499 effective changed lines (test files excluded in mixed PRs). label Nov 9, 2026
@Jacksondr5
Jacksondr5 merged commit a2d5164 into j5/main Nov 9, 2026
34 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/955-retire-stop-agent branch November 9, 2026 14:44

This branch was successfully deployed

1 active deployment
Preview — 9761be5f Deployed Nov 9, 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 PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retire j5_stop_agent for t3_thread_interrupt, keeping the Captain exemption

1 participant