Introduce decision points between steps using a handler that can STOP or CONTINUE.

Triage Example

from pydantic import BaseModel
class Triage(BaseModel):
  ambiguous: bool
  follow_up_details: str
  reply_to_user: str

def triage_handler(output: Triage):
  if output.ambiguous:
    return ("STOP", None)
  return ("CONTINUE", output.follow_up_details)

wf = (
  client.Workflow()
  .add(triage_agent, response_model=Triage, handler=triage_handler)
  .add(deep_dive_agent)
)
  • STOP: Returns the triage output to the caller immediately.
  • CONTINUE: Feeds the returned value as input to the next step.