Skip to main content

Stop Component

The <Stop> component signals that the workflow should terminate.

Basic Usage

import { Stop } from "smithers-orchestrator";

<Stop reason="Task completed successfully" />

Props

reason
string
Reason for stopping the workflow.
<Stop reason="Critical error encountered" />

Conditional Stop

import { useState } from "react";

function ConditionalWorkflow() {
  const [status, setStatus] = useState("running");

  return (
    <SmithersProvider db={db} executionId={executionId} maxIterations={10}>
      <If condition={status === "running"}>
        <Claude
          onFinished={(result) => {
            if (result.output.includes("CRITICAL")) {
              setStatus("error");
            } else if (result.output.includes("DONE")) {
              setStatus("complete");
            }
          }}
        >
          Process the task.
        </Claude>
      </If>

      <If condition={status === "error"}>
        <Stop reason="Critical error detected" />
      </If>

      <If condition={status === "complete"}>
        <Stop reason="Task completed" />
      </If>
    </SmithersProvider>
  );
}

With Human Rejection

<Human
  message="Approve?"
  onApprove={() => setPhase("continue")}
  onReject={() => setPhase("cancelled")}
>
  Review the changes.
</Human>

<If condition={phase === "cancelled"}>
  <Stop reason="Rejected by human" />
</If>