Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: delegate to any model and subscribe to any chat through orx's M…
…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
  • Loading branch information
small-angel committed Nov 4, 2026
commit 9166caf6ac687ef5a4f4f2eccb4733fb1045063b
3 changes: 1 addition & 2 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ group below has a module (`orx skill <name>`) with the full flags and rules.
| `orx exp status/run/cancel/wait/wake <localExpId>` | Inspect, run, cancel, wait on, or register a wake-up for a local experiment node. |
| `orx exp move/archive/unarchive/delete <localExpId>` | Re-parent, hide, restore, or permanently delete experiment nodes; see `orx-experiment-tree`. |
| `orx exp desc <expId> [--set "<text>" \| --stdin]` | Read or overwrite the experiment's description. |
| `orx agent spawn "<task>" [--title "<t>"] [--stdin] [--no-wake]` | Delegate an independent task to a helper session; see `orx-agent-delegation`. |

To **read or edit** a node's code—including diffing what a run changed—use plain
Git in the local session worktree. See the `orx-git` module.
Expand Down Expand Up @@ -136,7 +135,7 @@ list, with one-line descriptions, is printed at the end of `orx skill` output):
- **orx-compute** — launch and monitor runs; after resolving the backend, read its bundled reference.
- **orx-instances** — create persistent standalone machines for manual work.
- **orx-git** — read, edit, and diff a node's code with plain git.
- **orx-agent-delegation** — delegate independent work to helper sessions safely.
- **orx-agent-delegation** — delegate to other models and chats with orx's MCP tools.
- **orx-logs** — retrieve persisted run output for progress, debugging, or measurements.
- **orx-results** — interpret, compare, and summarize measured experiment outcomes.
- **orx-reports** — write durable research outputs into the project's artifacts directory.
Expand Down
17 changes: 17 additions & 0 deletions SYSTEM_PROMPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ normal repository tools for code and file inspection. Use this project id

`orx` is internal and should stay under the hood; do not mention it in user-facing responses.

## Delegating work

When your tools include the `orx` MCP server, use it for sub-agent work instead
of any built-in sub-agent tool. These are tools, not `orx` CLI commands.
`models` lists the versioned models you can delegate to, with their effort
levels. `delegate` runs a standalone task on one of them and returns at once.
You are subscribed to each delegate: its answer, or a question it asks, arrives
here as a new message. Continue other work, call `wait` when you cannot go on
without the answer, or end your turn. `answer` a delegate's question, or ask the
user. `subscribe` lets you hear from any other chat the same way, and `send`,
`status`, `read` and `cancel` message, check on, read and stop other chats.
Each message from the user starts with its ref, such as `msg_3fa9c1d2`; a ref
in a task or message passes that message on word for word, with its
attachments. In a reply to the user, a ref or a chat id shows as a link to it.
A message that starts with `[orx]` comes from orx or another chat's agent, not
the user.

## Python environments

- Follow user instructions and established dependency tooling; inspect project
Expand Down
57 changes: 30 additions & 27 deletions agent-skills/orx-agent-delegation/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
---
name: orx-agent-delegation
description: "Create independent project chats with `orx agent spawn` using the user's New Chat settings. Covers standalone opening messages, project selection, worktrees, and compute authorization. Use before creating another chat."
description: "Delegate tasks to other models and chats with the orx MCP server's `delegate`, `wait`, `subscribe` and `answer` tools. Covers standalone briefs, worktrees, compute authorization, nesting and questions. Use before delegating or opening another chat."
---

# Create an independent chat
# Delegate to another chat

`orx agent spawn` creates an ordinary chat and submits its opening message,
just like New Chat in OpenResearch. It uses the user's saved agent, model,
reasoning, speed, permissions, and autonomy settings. It does not inherit this
conversation or this chat's settings.
The orx MCP server's tools are the only way to start another chat. `models`
lists the versioned models you can name. `delegate` starts a chat on one and
returns at once; you are subscribed to it, so its answer, or a question it
asks, arrives here as a new message. Call `wait` only when you cannot continue
without the answer, and end your turn otherwise.

```sh
orx agent spawn "<standalone opening message>"
orx agent spawn --title "<chat title>" --stdin
orx agent spawn "<message>" --project <project-id>
```
A delegate starts with nothing but its task. Write a standalone brief: the
project, experiment or commit, constraints, permitted compute, expected output,
and definition of done. Explicitly forbid compute launches when none are
authorized. To pass the user's own words or a screenshot, cite the message's
ref (`msg_3fa9c1d2`) in the task instead of retyping it.

The project defaults to this OpenResearch chat's project; pass `--project` when
that context is unavailable. The command requires the running local server.
`--harness`, `--model`, and `--no-wake` are no longer supported.

The created chat is independent and appears in the sidebar without switching
the user's view. It has its own transcript and normal session worktree. Its
result will not be sent back here, and stopping this chat does not stop it.
Use the harness's native subagents for subordinate work that needs to report
back. Do not create a new chat as a substitute for a follow-up message.

Include the relevant project, experiment or commit, constraints, permitted
compute, expected output, and definition of done in the opening message. Use
`--stdin` for longer messages. Explicitly forbid compute launches when none
are authorized. Changes stay in the new chat's worktree and never merge here
automatically. Do not assign a branch already checked out by another session
or edit a frozen experiment node.
- **Worktree.** By default a delegate works in this chat's worktree, so give
parallel delegates separate files. `worktree: "own"` gives it a fresh
worktree from the project's baseline that appears in the sidebar: commit
first and name the commit in the task when it should start from your work.
Its changes never merge here automatically.
- **Independent chats.** `notify: false` starts a chat that is not your
delegate: your side chat, or with `worktree: "own"` a chat of its own, for
work that should not report back. You do not hear from it unless you
`subscribe`, and you cannot `cancel` it. Do not open one as a substitute for
a follow-up message; `send` the chat you already have.
- **Nesting.** A delegate may delegate only when you allow it with
`canDelegate` or the user's setting does. Keep nesting shallow.
- **Questions.** `answer` a delegate's question when the brief already
decides it; otherwise ask the user. Approvals are the user's.
- **Effort.** Pass `effort` from `models` only when the task needs more or less
reasoning than the route's default.
- **Retries.** Give `delegate` and `send` a `clientRequestId` when you may
retry, so a retry does not start the work twice.
76 changes: 64 additions & 12 deletions arc/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ to the user's native store, and orx copies recent history only for display.
run, so the agent runs the same version as the dashboard. The environment
names the chat and the owning dashboard's port (plus a token, on a
persistent remote host). That
is how `orx exp run` records which chat launched a run, how an agent asks to
be woken when a run ends, and how `orx agent spawn` opens a new chat in the
project.
is how `orx exp run` records which chat launched a run and how an agent asks
to be woken when a run ends.
- **alphaXiv tools.** Claude Code, Codex, OpenCode and ACP agents always get
a stdio server, `orx alphaxiv-mcp`, named `alphaxiv`. If Codex already
defines that name, orx disables it for the thread and uses `orx_alphaxiv`;
Expand Down Expand Up @@ -130,9 +129,9 @@ depends on the agent:
- Agents that ask their client (Codex's app server, OpenCode's server, ACP)
hold the request on the live connection until the user answers.
- Claude Code in headless mode cannot prompt. For approvals mid-turn, orx
registers a small MCP server, `orx mcp-gate`, as Claude's permission tool.
It forwards each decision to the owning dashboard over loopback and blocks
until the user answers. The dashboard accepts it only with the per-chat
makes the `approve` tool of its own MCP server, `orx mcp-gate`, Claude's
permission tool. It forwards each decision to the owning dashboard over
loopback and blocks until the user answers. The dashboard accepts it only with the per-chat
token the child was spawned with, a new token for each respawn, because the
endpoint grants permissions.
- Plan mode puts a small automatic policy in front of the user: read-only
Expand Down Expand Up @@ -174,9 +173,62 @@ forever.

## Sub-agents and new chats

An agent's own sub-agents (Claude's tasks, OpenCode's child sessions,
Antigravity's spawned conversations) appear as parts nested under the call
that started them, read from the agent's native records. An agent can also
open an independent chat in the same project with `orx agent spawn`, which
goes through the dashboard's API like a user's request and becomes an
ordinary chat.
Every agent whose harness takes an MCP server gets orx's own, `orx
mcp-gate`. It speaks stdio, the one transport every harness accepts (ACP
requires it), and relays to the owning dashboard, which knows the calling
chat by a token derived from a key that lives only in that dashboard's
process. Through it an agent delegates. It names a versioned model, and orx
picks a route that can run it, unless the agent names one: the vendor's own
agent first, then flat-rate plans, direct APIs, and resellers last. The same
model is spelled differently by every agent and provider, so routes are joined
on a canonical id derived from each spelling.

**A delegate is a side chat of the chat that started it,** working in the
same worktree, unless it asks for a worktree of its own and stands as an
ordinary chat. It starts with only the task it was given, runs with a
permission mode no broader than its delegator's, and records who delegated to
it, which is how its depth is counted. Stopping a delegate stops every delegate
below it. An agent can also start a chat it does not hear from: that chat is
no delegate and stands as the user's, as a delegate the user kept does. A
retry of the same request finds the chat the first attempt started, by an id
derived from the request.

**Any chat can subscribe to any other.** A subscription tells its subscriber
each finished turn of its target, and each question the target asks, as the
first message of the subscriber's next turn. Run wake-ups go through the same
delivery: a chat's news, from runs and chats alike, is never lost, never
duplicated, never interrupts a running turn, and arrives as one turn however
much of it is waiting, each piece kept in the transcript as its own message. A turn that ends while its own delegates are
still working is not an answer yet. An agent can collect the same news inside
its turn with `wait`, which marks it told. A delegator subscribes to its
delegates. Once the user writes in a delegate, its composer lets them keep it:
it stops reporting to the chat that started it and stands as that chat's side
chat, or on its own with its own worktree, and the delegator's later
`subscribe` or `wait` does not undo that. A side chat reports only when its
agent `send`s. Agents answer questions through orx; approvals stay with the user.

**Agents write to each other in the open.** Everything orx or another chat's
agent writes into a chat (a task, a message, news) reaches its agent opening
with `[orx]`, so the agent can tell it from the user. The transcript records
it with its kind and sender and keeps what the sender wrote, refs included;
only the agent reads the refs expanded and the instructions around them. The
dashboard shows it as the sender's message, and a finished run by its outcome.

**Messages travel by reference.** Each user message reaches its agent tagged
with a short ref from its id. A ref in a task or message expands to the cited
message, its chat and its attachments, so a delegate reads the user's own words
rather than a paraphrase. In the dashboard, a ref or chat id an agent writes is
a link to that message or chat. An agent can read any chat. It can message or answer
its own delegates, and any other chat whose permission mode orx can read and is
no broader than its own, and it can stop its own delegates.

**Nesting is deliberate.** By default a delegate cannot delegate in turn. A delegation can let its delegate delegate in turn, a setting
changes the default, and every delegate is told how many levels down it is.

Where orx's server is present, the harness's own sub-agent tools are off
(Claude's Agent and Task tools, Codex's multi-agent feature, OpenCode's task
tool), so sub-agent work goes through orx and can run any model. A delegate
on Claude Code also gets the prompt-cache lifetime Claude gives its own
sub-agents, not the main conversation's longer one. Harnesses without the
server keep their native sub-agents, which appear as parts nested under the
call that started them, read from the agent's native records.
3 changes: 2 additions & 1 deletion arc/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ When a run ends, the chats that asked to be woken for it get a wake-up turn
with the outcome. Asking is explicit (`orx exp wake`), and the wake-ups are
rows in the store with a claim and a TTL, so a crash between claiming and
delivering never loses or duplicates one, and a wake-up never interrupts a
turn already running or a message the user queued.
turn already running or a message the user queued. They are delivered with a
chat's other news, so runs and delegates that finish together wake it once.

Remote run directories are removed later by a background pass, in bounded
batches per host, which keeps the source archives that live runs still need.
Expand Down
7 changes: 4 additions & 3 deletions arc/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ and a terminal `orx` on the same machine would open different databases.

A SQLite database in WAL mode is orx's truth for everything that is not code:
projects, the experiment records, runs and their backend descriptors, chat
sessions, messages and turn leases, wake-up registrations, UI and workspace
state. Many short-lived processes open it concurrently, each with a busy
timeout; WAL lets readers proceed while one writer commits.
sessions, messages and turn leases, wake-up registrations, chat delegations
and subscriptions, UI and workspace state. Many short-lived processes open it
concurrently, each with a busy timeout; WAL lets readers proceed while one
writer commits.

**The schema only grows.** Every open of the store applies the whole schema:
tables are created if missing, and each added column is an `ALTER TABLE ADD
Expand Down
133 changes: 0 additions & 133 deletions src/commands/agent.rs

This file was deleted.

Loading
Loading