Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Remote agents

Run agents on other servers while keeping the same runAgent / run_agent model. Register remote targets with a receiverId / receiver_id on the same Workflow that owns the call.

Remote agents need WebSocket (transport: "ws") so request/reply messages can flow. Local-only workflows can still use HTTP.

Rules

  • Agents are never called directly — only a Workflow starts the first agent (entry → runAgent / run_agent), and nested calls use the same context APIs.

  • A name must be registered on that Workflow (local agent or remote receiver) before the call can resolve.

Register local vs remote

workflow.registerAgents({
  "formatter": formatterAgent,
  "outline-planner": { receiverId: "svc-agent-outline" },
});

const outline = await ctx.runAgent("outline-planner", { input: ctx.input });
workflow.register_agents({
    "formatter": formatter_agent,
    "outline-planner": {"receiver_id": "svc-agent-outline"},
})

outline = await ctx.run_agent("outline-planner", input_data=ctx.input)
workflow.registerAgents({
  'formatter': formatterAgent,
  'outline-planner': RemoteAgentRef(receiverId: 'svc-agent-outline'),
  // or: 'outline-planner': {'receiverId': 'svc-agent-outline'},
});

final outline = await ctx.runAgent('outline-planner', input: ctx.input);

Orchestrator

import { DNotifier } from "@dnotifier-realtime/dnotifier";

const notifier = new DNotifier({
  appId: process.env.DNOTIFIER_APP_ID,
  secret: process.env.DNOTIFIER_SECRET,
  userId: "svc-workflow",
  transport: "ws",
});

const workflow = new DNotifier.Workflow({
  name: "blog-pipeline",
  observability: true,
  async entry(ctx) {
    const outline = await ctx.runAgent("outline-planner", { input: ctx.input });
    ctx.state.outline = outline;
    const draft = await ctx.runAgent("content-creator", {
      input: { topic: ctx.input.topic, outline },
    });
    return { draft };
  },
}).registerAgents({
  "outline-planner": { receiverId: "svc-agent-outline" },
  "content-creator": { receiverId: "svc-agent-writer" },
});

await notifier.connect();
const run = await notifier.runWorkflow({
  workflow,
  input: { topic: "Realtime agents" },
});

Agent host

Host local agents on a Workflow, connect with the same userId as the orchestrator’s receiver id, then call listen.

listen answers remote invokes by building a WorkflowContext and calling runAgent / run_agent — not by calling the agent object directly.

Agent → agent (nested)

If agent A calls B and C, register B and C on the Workflow that owns that ctx (the host Workflow when A runs remotely).

Mid-run messages

Unblock with a normal send to the host’s userId. Remote-agent control messages are handled by the SDK and do not wake waitForMessage / wait_for_message.

Shared state

Remote invokes carry ctx.state. The host may update state; changes are merged back into the caller’s ctx.state when the reply returns.

Checklist

Step
Action

1

Same appId / secret on orchestrator and hosts

2

Host userId matches orchestrator receiverId / receiver_id

3

Both sides use transport: "ws" and connect()

4

Host calls workflow.listen(notifier)

5

Every agent name used in runAgent / run_agent is registered on that Workflow

Last updated