---
library: "bootstrap"
slug: "PromptChain"
name: "PromptChain"
ref: "PromptChain#02b5"
hash: "sema:PromptChain#mh:SHA-256:02b5f2277c89d51e35336a8735f5a8bf26304332db887961bb23790c8c82b2f9"
type: "Protocols"
layer: "Society"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/PromptChain"
---

# PromptChain

Sequential LLM calls with validation gates

Society · Protocols

## Mechanism

Decomposes a [Task](https://semahash.org/vocabularies/bootstrap/patterns/Task.md) into a fixed [Sequence](https://semahash.org/vocabularies/bootstrap/patterns/Sequence.md) of LLM calls. Each step's output is validated against an [AcceptSpec](https://semahash.org/vocabularies/bootstrap/patterns/AcceptSpec.md) before it is passed to the next, and a failed output is never forwarded. After a failed validation, the chain invokes [ReAttempt](https://semahash.org/vocabularies/bootstrap/patterns/ReAttempt.md) on that step up to `max_retries_per_step`; when that budget is exhausted, it halts without executing the next step. A value of zero halts on the first failed validation. It orchestrates [ToolInvoke](https://semahash.org/vocabularies/bootstrap/patterns/ToolInvoke.md) calls and applies [InputGuard](https://semahash.org/vocabularies/bootstrap/patterns/InputGuard.md) validation at each boundary.

## Invariants

- No failed-forwarding: the [Chain](https://semahash.org/vocabularies/bootstrap/patterns/Chain.md) never passes a failed step's output to the next step.
- Schema Continuity: Output(N) must satisfy InputSchema(N+1).
- Bounded recovery: a failed step is re-attempted no more than `max_retries_per_step`; exhaustion halts the [Chain](https://semahash.org/vocabularies/bootstrap/patterns/Chain.md) before the next step executes.

## Parameters

- max_retries_per_step: type=Integer, range=[0, 3], description=Re-attempts allowed after a failed step; 0 halts on the first failure

## Failure modes

- Undetected error propagation: a flawed intermediate output passes validation and corrupts the next step.
- Validation brittleness: an overly narrow [AcceptSpec](https://semahash.org/vocabularies/bootstrap/patterns/AcceptSpec.md) rejects a valid intermediate output.

## Where this came from

—

## Builds on

- [ToolInvoke](https://semahash.org/vocabularies/bootstrap/patterns/ToolInvoke.md) (composes_with)
- [InputGuard](https://semahash.org/vocabularies/bootstrap/patterns/InputGuard.md) (composes_with)
- [ReAttempt](https://semahash.org/vocabularies/bootstrap/patterns/ReAttempt.md) (composes_with)
- [AcceptSpec](https://semahash.org/vocabularies/bootstrap/patterns/AcceptSpec.md) (references)
- [Chain](https://semahash.org/vocabularies/bootstrap/patterns/Chain.md) (references)
- [Sequence](https://semahash.org/vocabularies/bootstrap/patterns/Sequence.md) (references)
- [Task](https://semahash.org/vocabularies/bootstrap/patterns/Task.md) (accepts)

## Used by

- [Compose](https://semahash.org/vocabularies/bootstrap/patterns/Compose.md) (references)
- [MetaPrompt](https://semahash.org/vocabularies/bootstrap/patterns/MetaPrompt.md) (references)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: PromptChain#02b5
- Hash: sema:PromptChain#mh:SHA-256:02b5f2277c89d51e35336a8735f5a8bf26304332db887961bb23790c8c82b2f9

## Links

- Page: https://semahash.org/vocabularies/bootstrap/patterns/PromptChain
- JSON: https://semahash.org/vocabularies/bootstrap/patterns/PromptChain.json
- Library: https://semahash.org/vocabularies/bootstrap
- Library index: https://semahash.org/vocabularies/bootstrap/index.json
