← Back
AWS ML Blog

Agentic retrieval with LangChain and Amazon Bedrock Knowledge Bases

•16 min read•
#agents#bedrock#langchain
Level:Advanced
For:AI Engineers
✦TL;DR

This article introduces agentic retrieval on Amazon Bedrock Managed Knowledge Bases, where the AgenticRetrieveStream API breaks a multi‑part query into sub‑queries, iteratively searches, and streams planning trace events. The langchain‑aws package exposes both the standard Retrieve API (single‑shot hybrid search) and the agentic AgenticRetrieveStream API for seamless integration into LangChain pipelines. Engineers can choose the cheaper standard retrieval when a single search suffices, or the more thorough agentic path for complex, multi‑intent questions.

⚡ Key Takeaways

  • The Retrieve API runs one hybrid search and returns scored chunks.
  • The AgenticRetrieveStream API runs a planning loop, streaming trace events for each sub‑query.
  • The langchain‑aws package provides a standard LangChain retriever for the Retrieve API and a function retrieval interface for AgenticRetrieveStream.
  • The walkthrough assumes Python 3.12+, an AWS account with Bedrock access in us-east-1, and an S3 bucket containing the source documents.
  • Agentic retrieval incurs higher cost due to multiple search iterations, making the standard Retrieve API preferable for simple queries.
💡 Why It Matters

Selecting the appropriate retrieval mode lets engineers balance cost and answer completeness, enabling production RAG systems that can handle complex user intents without over‑provisioning resources.

✅ Practical Steps

  1. Install the langchain‑aws package and configure it with your AWS credentials and the Bedrock Knowledge Base ID.
  2. Use the Retrieve API for single‑shot searches by creating a standard LangChain retriever instance.
  3. For complex queries, invoke the AgenticRetrieveStream API via the langchain‑aws function retrieval to receive streamed planning events and assembled results.

Want the full story? Read the original article.

Read on AWS ML Blog ↗

More like this

New in AWS Quick: More capable flows, an updated web experience, and agents that work together

AWS ML Blog•#agents

How Google Duplex evolved to also call businesses for you in Gemini

Google Research•#agents

Genie ZeroOps, now in public beta: An autonomous agent that fixes data pipelines, with lessons from 80,000 customer issues

Databricks Blog•#agents

Towards a Science of Capable Autonomous Agents & Provable Safety — Part II

CMU ML Blog•#agents

EXPLORE AI NEWS

Daily hand-picked stories on LLMs, RAG, agents and production AI — curated for engineers who ship.

BROWSE NEWS

GET THE WEEKLY DIGEST

Join engineers getting the Monday signal-over-noise AI breakdown. No spam, unsubscribe anytime.

LEARN AI ENGINEERING

Curated courses, research papers, repos and tutorials built for engineers leveling up in AI.

START LEARNING