Skip to main content
Your support ops orchestrator triages an escalation, then hands off response drafting to a worker agent. This recipe models the full handoff lifecycle with sessions, child runs, workflow steps, and handoff events. Source: multi-agent-pipeline.ts · multi_agent_pipeline.py

Scenario

An urgent enterprise support ticket arrives. The orchestrator triages it, requests a handoff to a response worker, and the worker composes a reply.

The timeline

  1. Sessionkind: "pipeline" groups the full escalation
  2. Orchestrator runstepKey: "orchestrator", stepIndex: 0
  3. Triage stepwithWorkflowStep for ticket triage
  4. Handoff requestedtrackHandoffRequested with ticket metadata
  5. Child worker runwithChildRun with role: "worker"
  6. Handoff completedtrackHandoffCompleted
  7. Compose replywithTool for support.compose_reply

Key code blocks

Handoff requested

await apie.trackHandoffRequested({
  sessionId: session.id,
  sourceRunId: orchestratorRun.id,
  reason: "Delegate customer response draft",
  payloadSummary: { ticketId: "SUP-123", priority: "urgent" },
});

Child worker run

await apie.withChildRun(
  {
    sessionId: session.id,
    parentRunId: orchestratorRun.id,
    stepKey: "response-worker",
    stepName: "Response worker",
    stepIndex: 2,
    role: "worker",
  },
  async (workerRun) => {
    await apie.trackHandoffCompleted({ sessionId: session.id, runId: workerRun.id });
    // worker logic
  },
);

What you’ll see

A session replay showing orchestrator triage, handoff requested/completed events, and the worker’s compose-reply tool call — all in chronological order.

Full example

See Multi-agent pipelines for the complete code listing.

Next steps

Trace runs and sessions

Run and session fundamentals.

Custom telemetry

Handoff and workflow events.