Human review and waits
Pause a run for a person's decision, an event from another system, or a wake time, and read the outcome safely.
Pause a run for a person’s decision, an event from another system, or a wake time, and read the outcome safely.
Wait for a review, an event or a time
A workflow body pauses for a person’s decision, an event another system sends, or a wake time. The run parks and resumes when the response, event or time arrives.
-
wait_for_review(Schema, subject=result, context=..., timeout="72h")suspends for a human decision.subjectis required and must be the result of a step or primitive call, not a field of one, so Andon can snapshot its producer provenance. A reviewer who needs several results gets a tuple or record of whole results, such assubject=(summary, risks); the review depends on each result you pass to the tuple or record.contextis optional presentation material. PutFileRefs (not filename strings) in the context for any documents the reviewer needs; the console renders each as an openable evidence chip. Usewait_for_event(Schema, timeout=...)for API signals. The run importsSchemaby name when a response arrives, so declare it as a class at module scope under its own name, or use a builtin, aLiteralof strings, numbers, booleans orNone, or a list, dict, tuple, or union of those; deploy rejects anAnnotatedtype, a class defined inside a function, or aLiteralof enum members. Both returnWaitOutcome[Schema], a union ofWaitCompleted[Schema](withvalueandtimed_out=False) andWaitTimedOut(with onlytimed_out=True). Branch on the bare.timed_outfield, then read.valueonly in that branch’sfalse=arm; deploy validation rejects unguarded projections. Passing or returning the whole union is legal when the consumer handles both variants. The label defaults to the result’s variable binding; passlabel=when the external rendezvous identity must differ. Labels use the stable-key grammar[a-z_][a-z0-9_]*. Timeout is required. Durations are strings:"30s","5m","2h","7d". Run signal discovery reports the stable label and the current event occurrence id. Responders use that id to read the event detail, including a review’s subject and subject schema, and to submit a response without risking a later occurrence that reused the label. -
wait_for_event(Schema, metadata=Record(...), timeout=...)says what the wait is about, such as the email thread it waits on, so a Gmail trigger can answer it (see Triggers).metadatais an instance of a dataclass or Pydantic model declared at module scope, built from workflow values; deploy rejects any other value. It is stored once with the wait and shown in the event detail as declared.contextstays what a responder is shown and is not matched on. -
sleep(duration, then=...)orsleep(until=..., then=...)durably waits, then runsthenand returns its result. Pass exactly one ofdurationanduntil;thenis required.thenis an arm, as inbranch: a call written inside it runs after the wake, and a local body holds several calls.durationis a constant such as"3d", counted from when the sleep becomes eligible: once every value its arm uses is ready and, for a sleep inside abrancharm, once that arm is chosen.untilis a workflow value that resolves to a timezone-awaredatetime, such as a field of the input, a step’s result or a constant cutoff; it is validated where the sleep runs. The arm runs at the later of the wake time and its values being ready, and a time already past wakes at once. A result bound before the sleep is computed on its own schedule, sosleep("3d", then=status)makesstatusavailable three days after it is ready. The wake time is fixed when the sleep becomes eligible; when it falls after the end of the run’s life the run fails at once. A polling loop isbody=lambda state: sleep("1d", then=check(state)).review = wait_for_review(Decision, subject=prepare_review(claim), timeout="10d") approved = is_approved(review) return branch(approved, true=sleep("3d", then=send_reminder(claim))) # approved on day 5: the reminder goes out on day 8