Skip to content

feat: rework entirely how subagents work - #885

Merged
small-angel merged 4 commits into
mainfrom
clo/agent-orchestration
Nov 4, 2026
Merged

small-angel merged 4 commits into
mainfrom
clo/agent-orchestration

Conversation

@small-angel

@small-angel small-angel commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

An agent could only start sub-agents on its own harness and model, and no chat could hear back from or write to another, so cross-model work meant separate sessions and copy-paste.

orx now gives every agent its own MCP server, orx mcp: delegate starts a chat on any model, with orx picking the route, and the delegator is woken with its answer. Any chat can subscribe, wait, send and answer across providers, and the harnesses' own sub-agent tools are off, so all sub-agent work shows up in the dashboard.

Proved with CI, three Sol review rounds and Greptile's, and runs on a dev server: an OpenCode agent calling orx mcp's tools, Stop reaching a running delegate, and citations opening across forks and projects.

Closes #608.

Assisted-by: claude-opus-5.5

@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[High impact] The PR changes how agent work is started and coordinated across supported harnesses.

Fix duplicate news delivery after a server restart before merging.

Findings

  1. P1 Delegate answers arrive twice ▶
Fix with agent prompt
### Issue 1
src/local/chat/news.rs:460-463
`deliver_news` saves and starts the receiving turn before marking its news as told. If the server exits between those steps, the subscription becomes ready again after its claim expires. The next delivery gets a new random `client_turn_id`, so it starts another turn instead of finding the saved one. The agent can receive and act on the same answer twice.

Save the news receipt with the receiving turn, or use a stable delivery key and recognize an already-saved delivery.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Replaces built-in sub-agents with chats managed through the orx MCP server.

  • Agents delegate tasks through OpenResearch across harnesses.
  • Chats receive delegate updates and run results as messages.
  • The dashboard shows who sent agent messages and where delegate work stands.

Diagram

sequenceDiagram
  participant Agent
  participant MCP as orx MCP
  participant Server as Dashboard server
  participant Store
  participant Delegate
  Agent->>MCP: delegate(task, model)
  MCP->>Server: Authenticated tool call
  Server->>Store: Save delegate and subscription
  Server->>Delegate: Start task
  Delegate->>Store: Save answer
  Server->>Store: Claim pending news
  Server->>Store: Save receiving turn
  Note over Server,Store: A restart here permits duplicate delivery
  Server->>Store: Mark news told
Loading

Reviews (5) · Last reviewed commit: "fix: stop a chat's delegates with it, an..." · Reviewed by Greptile

Comment thread src/local/chat/mod.rs Resolved
Comment thread src/commands/up/agent_tools.rs Resolved
Comment thread src/local/chat/delegation.rs Resolved
Comment thread ui/src/api.ts Resolved
Comment thread ui/src/components/ChatPanel.tsx Resolved
@small-angel
small-angel force-pushed the clo/agent-orchestration branch from 845f7aa to 8a6c698 Compare November 4, 2026 19:07
@small-angel

Copy link
Copy Markdown
Contributor Author

comment written by Claude Opus 5.5

@greptileai review

Comment thread ui/src/components/ChatPanel.tsx Resolved
…CP server

Agents get orx's own MCP server, `orx mcp-gate`, beside alphaXiv's on
every harness that takes one: Claude via --mcp-config, Codex through its thread config, OpenCode
through its config, and ACP agents in session/new, load and resume (stdio,
which ACP requires every agent to accept). Beside Claude's `approve`, it
relays orchestration tools to `orx up` at /api/internal/mcp, which
authenticates the chat by a token derived from a per-process key. Claude
loads the server's tools upfront rather than behind tool search, and
Codex and OpenCode give it a tool timeout past the longest `wait`.

- models: versioned models, the routes that run them in default order
  (vendor harness, OpenCode Go, OpenCode, direct APIs, other harnesses,
  aggregators) and the effort levels the first route takes. Routes join on
  a canonical id; Claude aliases join through the catalog's resolvedModel,
  and ACP agents are named by a slug of their name.
- delegate: a chat on the resolved route and effort, a side chat in the
  caller's worktree or (`worktree: own`) a chat with its own, with a
  permission mode no broader than the caller's. chat_delegates records who
  delegated, which is how depth is counted; a retry with the same
  clientRequestId finds the first chat by an id derived from it. The caller
  subscribes, unless `notify: false`, which starts a chat that is no
  delegate: the caller's side chat, or with `worktree: own` a chat of its
  own, as a delegate the user kept. canDelegate decides whether the delegate may delegate in
  turn; it defaults to a new setting, off, and each delegate is told its
  depth.
- subscribe, unsubscribe, wait: any chat can subscribe to any other. A
  subscription tells each finished turn, and each question the target
  asks, as the first message of the subscriber's next turn, through the
  same leased, idle-only loop as run wake-ups, batched into one turn per
  subscriber with each piece kept in the transcript as its own message. A
  turn that ends asking, or while the target's own delegates work, is not
  its answer; answers a later turn overtook ride along with its news.
  `wait` collects the same news inside a turn and marks it told as it
  returns it, so it never arrives twice.
- answer: answers a forwarded question through the dashboard's own prompt
  path, and the card shows which chat answered. Approvals, OpenCode's plan
  exit included, stay with the user.
- status, read, send, cancel: read any chat; message a delegate, or any
  chat with no broader permissions; stop a delegate and every delegate
  below it.

Run wake-ups now go through the same delivery as subscriptions, so a chat
hears every run and chat that finished in one turn instead of one turn per
run, and the second wake-up loop is gone. `orx agent spawn` is removed:
`delegate` with `notify: false` and `worktree: own` opens an independent
chat on any model, and the orx-agent-delegation skill now teaches the MCP
tools. Transcripts that used spawn still render its card.

Each user message reaches its agent tagged with a ref, the start of its
id (msg_3fa9c1d2), which no colour or longer id can be mistaken for. A
ref in a task or message expands, for the receiving agent only, to the
cited message as a quote with its author, chat and attachments, so a
delegate reads the user's own words; one that cites nothing stays as
written. Everything orx or another agent writes into a chat (a task, a
`send`, news) reaches its agent opening with `[orx]`, and its part in the
transcript records its kind and sender (`orx: {kind, from, status}`)
beside the words the sender wrote, through new turns, steering and the
queue alike. The dashboard reads that rather than the text: a collapsed
card on the left whose sender opens that chat and whose first line opens
the whole message, and for a run, its experiment, outcome and how long it
ran in green, red or amber, opening its logs. In chat, a ref is an inline pill with the
cited message's first words and its author's icon (the agent's provider
for an agent's message) that opens that chat at the message, and a chat
id is a link named after the chat. A side chat's or delegate's opening
context names the chat it came from, so `send` back needs no lookup.
Native sub-agent tools are off where the server is present (Claude
Agent/Task/Workflow, Codex multi_agent, OpenCode task), and Claude
delegates get the subagent prompt-cache TTL instead of the main
conversation's 1h. A side chat's worktree owner is now the top of its
chain, since delegates nest.

The dashboard shows delegates as a lineage rather than side chats: the
session JSON carries each delegate's parent, depth, latest turn state, what
it waits on and a preview of its answer or failure; the side chat menu
leaves delegates out; the workspace pane lists active sub-agents (nested
ones indented, ones waiting on an answer marked) with finished ones folded
behind a count; and each delegate gets a card in the transcript under the
turn that started it. Once the user writes in a delegate, a bell in its composer
lets them keep it: it stops notifying the parent agent and becomes that
chat's side chat (or a chat of its own, with its own worktree). Side chats
have no bell; their agent `send`s when asked.
Side chat tooltips in the workspace pane open beside the row instead of
over the menu.

Assisted-by: claude-opus-5.5
@small-angel
small-angel force-pushed the clo/agent-orchestration branch from 8a6c698 to 9166caf Compare November 4, 2026 19:18
@small-angel

Copy link
Copy Markdown
Contributor Author

comment written by Claude Opus 5.5

@greptileai review

@small-angel
small-angel added this pull request to stack #888 November 4, 2026 19:27
@small-angel small-angel changed the title feat: delegate to any model and subscribe to any chat through orx's MCP server feat: rework entirely how subagents work Nov 4, 2026
@small-angel

Copy link
Copy Markdown
Contributor Author

comment written by Claude Opus 5.5

@greptileai review

Comment thread src/commands/up/agent_tools.rs Resolved
Comment thread src/commands/up/agent_tools.rs Resolved
Comment thread ui/src/App.tsx Resolved
…rx mcp`

The user's Stop now stops the chat's delegates too, as an agent's
`cancel` already did; otherwise their answers woke the chat the user had
just stopped. A `send` retry is keyed by the calling chat and request
alone, so it still matches after a restart, and a message cited from
another project opens there.

`orx mcp-gate` stopped being only Claude's approval gate once every
harness spawned it for the orchestration tools. `mcp-gate` stays a hidden
alias: an `orx up` running from before an update still writes configs
that launch it from the updated binary.

Assisted-by: claude-opus-5.5
@small-angel
small-angel force-pushed the clo/agent-orchestration branch from bbd7aac to 5bc0015 Compare November 4, 2026 19:50
@small-angel

Copy link
Copy Markdown
Contributor Author

comment written by Claude Opus 5.5

@greptileai review

Comment thread src/local/chat/news.rs Resolved
@small-angel
small-angel removed this pull request from stack #888 November 4, 2026 20:12
@small-angel
small-angel merged commit 2b8636a into main Nov 4, 2026
13 checks passed
@small-angel
small-angel deleted the clo/agent-orchestration branch November 4, 2026 20:13
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.

Allow cross-harness sub-agents

1 participant