Skip to main content

Orchestration Component

The <Orchestration> component provides top-level control over workflows, including global timeouts, stop conditions, VCS snapshots, and cleanup.

Basic Usage

import { Orchestration } from "smithers/smithers-orchestrator/src/components/Orchestration";

<SmithersProvider db={db} executionId={executionId}>
  <Orchestration
    globalTimeout={3600000}
    onComplete={() => console.log("Done")}
  >
    <Claude>Do the work.</Claude>
  </Orchestration>
</SmithersProvider>

Props

globalTimeout
number
Maximum time in milliseconds for the entire workflow.
<Orchestration globalTimeout={3600000}>  {/* 1 hour */}
stopConditions
StopCondition[]
Conditions that stop the workflow early.
<Orchestration
  stopConditions={[
    { type: "total_tokens", value: 100000 },
    { type: "total_agents", value: 50 },
  ]}
>
snapshotBeforeStart
boolean
Create a VCS snapshot before starting.
cleanupOnComplete
boolean
Run cleanup when workflow completes.
onComplete
() => void
Called on successful completion.
onError
(error: Error) => void
Called on workflow failure.
onStopRequested
() => void
Called when stop is requested.

Stop Conditions

Token Limit

{ type: "total_tokens", value: 100000 }

Agent Limit

{ type: "total_agents", value: 20 }

Time Limit

{ type: "total_time", value: 1800000 }  // 30 minutes

Report Severity

{ type: "report_severity", value: "critical" }

CI Failure

{ type: "ci_failure" }

Custom

{
  type: "custom",
  fn: (result) => result.output.includes("ABORT"),
  message: "Abort requested"
}

Full Example

<SmithersProvider db={db} executionId={executionId}>
  <Orchestration
    globalTimeout={3600000}
    snapshotBeforeStart
    stopConditions={[
      { type: "total_tokens", value: 50000 },
      { type: "report_severity", value: "critical" },
    ]}
    onComplete={() => {
      console.log("Workflow completed successfully");
    }}
    onError={async (error) => {
      await db.vcs.addReport({
        type: "error",
        severity: "critical",
        title: "Workflow Failed",
        content: error.message,
      });
    }}
    onStopRequested={() => {
      console.log("Stop condition triggered");
    }}
  >
    <Ralph maxIterations={10}>
      <WorkflowContent />
    </Ralph>
  </Orchestration>
</SmithersProvider>