4.2.4. Open-Source Orchestration: LangChain and LlamaIndex
💡 First Principle: Native Bedrock Agents and Knowledge Bases cover the common orchestration paths with the least code and the most AWS integration — but when an application needs an integration they do not offer, custom retrieval logic, or portability across model providers, an open-source orchestration framework fills the gap. The exam expects you to know when to reach past the native services, not just that the frameworks exist.
Native vs. open-source orchestration — the trade-off:
| Dimension | Native (Bedrock Agents / Knowledge Bases) | Open-source (LangChain / LlamaIndex) |
|---|---|---|
| Operational overhead | AWS-managed; minimal code | You build and operate the orchestration code |
| Integrations | Managed connector list | Any source or tool you can write a wrapper for |
| Portability | AWS-specific | Provider-agnostic; swap models or clouds |
| Custom retrieval logic | Limited to managed options | Full control over the pipeline |
| Best when | Standard RAG/agents, fastest delivery | A need the native services do not yet cover |
LangChain on AWS — the integration points that matter:
ChatBedrockis LangChain's class for calling Bedrock chat models. LangChain orchestrates the chain, custom tools, and any third-party component (for example a reranker Bedrock Agents does not integrate natively) while Bedrock still serves the model. LangChain calls Bedrock directly — you do not abandon Bedrock to use LangChain.DynamoDBChatMessageHistoryprovides durable, shared conversation memory. It persists each session's messages to an Amazon DynamoDB table keyed by session ID, so any stateless compute instance (Lambda, Fargate task) can read and append the same history. In-process buffers or local-RAM memory are lost when an instance recycles and are not shared across a fleet.
LlamaIndex — the data framework: LlamaIndex specializes in connecting custom data sources, building indexes, and defining retrieval logic. Reach for it when a source is not on the Bedrock Knowledge Bases connector list, or when you need ingestion and retrieval behavior the managed pipeline does not provide.
⚠️ Common Misconception: "Using LangChain means replacing Bedrock." LangChain and LlamaIndex are orchestration layers that sit on top of Bedrock — ChatBedrock invokes Bedrock models directly. You add a framework for flexibility and portability, not to remove AWS from the stack. The cost is that you now operate the orchestration code yourself; the native services manage that for you.
Reflection Question: Your team needs a chatbot whose conversation memory survives across sessions and across a fleet of stateless Lambda functions, and which chains a third-party reranker that Bedrock Agents does not support. Which framework and which AWS service back the memory, and what do you give up by not using the native services?