3.3.4. Prompt Flows and Chaining
💡 First Principle: Complex GenAI tasks often require sequential reasoning — the output of one FM call informs the next. Prompt Flows provide a visual, managed orchestration layer for multi-step FM workflows, eliminating the need to write custom orchestration code for common chaining patterns.
Amazon Bedrock Prompt Flows enables no-code/low-code orchestration of:
- Sequential FM calls (output of step 1 → input of step 2)
- Conditional branching (route based on FM output classification)
- Knowledge Base retrieval steps
- Lambda function steps (external data enrichment)
- Input/output transformation
Example: document analysis pipeline as a Prompt Flow:
Input: raw_document
↓
Step 1 (FM): "Extract the 5 key topics from this document" → topic_list
↓
Step 2 (Knowledge Base): Retrieve relevant context for each topic → context_per_topic
↓
Step 3 (Lambda): Format and merge retrieved contexts → enriched_context
↓
Step 4 (FM): "Given these topics and context, generate an executive summary" → summary
↓
Step 5 (Conditional): IF summary length > 500 words → Step 6 ELSE → Output
↓
Step 6 (FM): "Condense this summary to 300 words" → concise_summary
↓
Output: concise_summary
When to use Prompt Flows vs. Bedrock Agents vs. Step Functions:
| Orchestration | Best For | Not For |
|---|---|---|
| Bedrock Prompt Flows | Structured multi-step FM workflows; visual design; predictable paths | Dynamic tool selection; long-running processes |
| Bedrock Agents | Autonomous reasoning; dynamic tool calling; variable number of steps | Deterministic workflows; real-time latency requirements |
| Step Functions | Complex orchestration with many services; durable execution; long-running | Simple FM chaining |
⚠️ Exam Trap: Bedrock Prompt Flows runs synchronously and has execution time limits. For workflows that might take hours (processing large documents, batch operations), use Step Functions + Lambda with asynchronous Bedrock invocations — not Prompt Flows.
Reflection Question: You need to build a pipeline that: (1) classifies incoming documents by type, (2) routes each type to a different FM prompt for extraction, and (3) validates the extraction output against a schema before writing to DynamoDB. Would you implement this as a Prompt Flow, Bedrock Agent, or Step Functions workflow? Justify your choice.