Skip to main content

useSmithersSubagent Hook

Runs the same execution pipeline as <Smithers>, but returns state for custom rendering. The source of truth is the Smithers DB (agents + state tables).
import { useSmithersSubagent } from "smithers-orchestrator";

function SubagentPanel() {
  const { status, result, error } = useSmithersSubagent({
    plannerModel: "opus",
    executionModel: "sonnet",
    children: "Plan + implement the migration.",
  });

  return (
    <panel>
      <text>Status: {status}</text>
      {error && <text>Error: {error.message}</text>}
      {result && <text>Output: {result.output}</text>}
    </panel>
  );
}

API

function useSmithersSubagent(props: SmithersProps): UseSmithersSubagentResult

interface UseSmithersSubagentResult {
  status: "pending" | "planning" | "executing" | "complete" | "error"
  subagentId: string | null
  executionId: string | null
  plannerModel: string
  executionModel: string
  result: SmithersResult | null
  error: Error | null
}

Props

PropTypeDefaultDescription
childrenReactNodeTask description
plannerModelClaudeModel'sonnet'Model to use for planning the script
executionModelClaudeModel'sonnet'Model for Claude agents in the generated script
maxPlanningTurnsnumber5Maximum turns for the planning phase
timeoutnumber600000Timeout in milliseconds (default 10 min)
contextstringAdditional context to provide to the planner
cwdstringWorking directory for script execution
keepScriptbooleanfalseKeep the generated script after execution
scriptPathstringCustom path for the generated script (implies keepScript)
onProgress(message: string) => voidCalled for progress updates
onScriptGenerated(script: string, path: string) => voidCalled when the script is generated (before execution)

Notes

  • Requires SmithersProvider context.
  • Uses DB state for resumability (subagent id + substatus).