Skip to main content

Stop Component

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

Basic Usage

import { Stop } from "smithers";

<Stop reason="Task completed successfully" />

Props

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

Conditional Stop

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

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

      {status() === "error" && (
        <Stop reason="Critical error detected" />
      )}

      {status() === "complete" && (
        <Stop reason="Task completed" />
      )}
    </Ralph>
  );
}

With Human Rejection

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

{phase() === "cancelled" && (
  <Stop reason="Rejected by human" />
)}