Prompt chaining with gates
artifactclosed gatemissing citation
- Task decomposition: outline, draft, polish.
- Gate 1: programmatic schema validation passes.
- Gate 2 fails on a missing citation; retry is local.
- Validation passes; the artifact enters the final stage.
Notes & references
Use when
Fixed subtasks with cheap programmatic validators.
Avoid
Dynamic decomposition or tight latency budgets.
outline = llm("Write an outline", topic)
assert has_all_sections(outline) # check 1: plain code
for attempt in range(3):
draft = llm("Write the draft", outline)
if has_sources(draft): # check 2: plain code
break
return llm("Polish the text", draft)
- Building effective agentsAnthropic
- Workflows and agentsLangChain
- Demystifying evals for AI agentsAnthropic