<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saurabh "Rob" Dahal</title>
    <description>The latest articles on DEV Community by Saurabh "Rob" Dahal (@raabdahl).</description>
    <link>https://dev.to/raabdahl</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3709480%2F8d520395-4d17-449e-a5db-9dd63f9c5f62.jpeg</url>
      <title>DEV Community: Saurabh "Rob" Dahal</title>
      <link>https://dev.to/raabdahl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raabdahl"/>
    <language>en</language>
    <item>
      <title>I Let My AI Agent Build a Bedrock RAG Knowledge Base, Here Are the 2 Mistakes the AWS Agent Toolkit Caught</title>
      <dc:creator>Saurabh "Rob" Dahal</dc:creator>
      <pubDate>Thu, 25 Jun 2026 18:29:01 +0000</pubDate>
      <link>https://dev.to/raabdahl/i-let-my-ai-agent-build-a-bedrock-rag-knowledge-base-here-are-the-2-mistakes-the-aws-agent-toolkit-3l49</link>
      <guid>https://dev.to/raabdahl/i-let-my-ai-agent-build-a-bedrock-rag-knowledge-base-here-are-the-2-mistakes-the-aws-agent-toolkit-3l49</guid>
      <description>&lt;p&gt;&lt;em&gt;Provisioning a Bedrock RAG knowledge base with S3 Vectors, without the hallucinated API calls.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you've asked an AI coding agent to set up AWS, you've seen it confidently invent a parameter, reach for a deprecated service, or burn ten minutes retrying against a service it never saw in training. The failure mode that bites hardest is the silent one: the agent &lt;em&gt;thinks&lt;/em&gt; it succeeded, and you find out an hour later.&lt;/p&gt;

&lt;p&gt;I hit two of these while standing up the retrieval layer for a LangGraph support bot, an Amazon Bedrock Knowledge Base backed by Amazon S3 Vectors. I'd love to say I caught both with deep AWS expertise. I caught them because the &lt;a href="https://github.com/aws/agent-toolkit-for-aws" rel="noopener noreferrer"&gt;Agent Toolkit for AWS&lt;/a&gt; read the docs I hadn't. Both would have shipped, and neither did.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 30-second setup
&lt;/h2&gt;

&lt;p&gt;The goal: take a folder of markdown product docs and make them queryable by meaning, so an agent can answer "is this safe for color-treated hair?" from the real docs instead of guessing. Think of it as giving the agent a library it can search instead of making things up. That's the &lt;em&gt;retrieval&lt;/em&gt; half of RAG, the foundation a LangGraph agent will later call as a tool.&lt;/p&gt;

&lt;p&gt;Four moving parts, wrapped in one managed service:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Source bucket&lt;/strong&gt;: an S3 bucket holding the docs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embeddings&lt;/strong&gt;: Amazon Titan Text Embeddings V2 (1024-dim vectors).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector store&lt;/strong&gt;: Amazon S3 Vectors. I chose it over OpenSearch Serverless because it has no always-on compute, the difference between cents and a monthly surprise for a demo that sits idle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Knowledge Base&lt;/strong&gt;: Amazon Bedrock Knowledge Bases ties it together into one thing you can query with a &lt;code&gt;retrieve&lt;/code&gt; call.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To follow along, you need an AWS account, a non-root IAM identity with credentials configured locally, &lt;a href="https://docs.astral.sh/uv/" rel="noopener noreferrer"&gt;uv&lt;/a&gt; installed, and the toolkit installed in your agent. The fastest path across Kiro, Claude Code, Cursor, and Codex is the AWS CLI installer, &lt;a href="https://aws.amazon.com/about-aws/whats-new/2026/06/aws-cli-agent-toolkit/" rel="noopener noreferrer"&gt;&lt;code&gt;aws configure agent-toolkit&lt;/code&gt;&lt;/a&gt;; in Kiro you can instead add the &lt;a href="https://aws.amazon.com/blogs/aws/the-aws-mcp-server-is-now-generally-available/" rel="noopener noreferrer"&gt;AWS MCP Server&lt;/a&gt; to &lt;code&gt;.kiro/settings/mcp.json&lt;/code&gt; (pin the &lt;a href="https://pypi.org/project/mcp-proxy-for-aws/" rel="noopener noreferrer"&gt;&lt;code&gt;mcp-proxy-for-aws&lt;/code&gt;&lt;/a&gt; version) and run &lt;code&gt;npx skills add aws/agent-toolkit-for-aws/skills&lt;/code&gt;. The toolkit plugs into the agent you already use and loads task-specific &lt;em&gt;skills&lt;/em&gt; on demand; I used the &lt;code&gt;amazon-bedrock&lt;/code&gt; skill, which carries the validated, current procedure for building a Knowledge Base. That word, "current," is the whole story.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gotcha #1: the model id was already dead
&lt;/h2&gt;

&lt;p&gt;My first instinct, straight from an older tutorial, was &lt;code&gt;anthropic.claude-3-5-sonnet-20240620-v1:0&lt;/code&gt;. Calling it returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ResourceNotFoundException: This model version has reached the end of its life.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fix the toolkit's doc search surfaced: current Anthropic models on Bedrock are &lt;strong&gt;inference-profile only&lt;/strong&gt;. You invoke them through a cross-region profile id like &lt;code&gt;us.anthropic.claude-sonnet-4-5-20250929-v1:0&lt;/code&gt;, not the bare on-demand id.&lt;/p&gt;

&lt;p&gt;On its own, an agent might not even diagnose this correctly. "Not found" reads like a permissions or region problem, so it could swap in another stale id and hit "on-demand throughput isn't supported" instead, flailing sideways. The toolkit got it right because it read the current model docs, not because it happened to remember them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gotcha #2: Bedrock won't create the S3 Vectors index for you
&lt;/h2&gt;

&lt;p&gt;I created the vector bucket, pointed the Knowledge Base at an index name, and assumed Bedrock would create the index. It didn't:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ValidationException: The specified index could not be found (S3Vectors 404)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real requirement, from the S3 Vectors docs: you create the index yourself, and it must declare two &lt;strong&gt;non-filterable metadata keys&lt;/strong&gt; that Bedrock uses to store chunk text and metadata. Miss them and ingestion fails later with a cryptic error far from the cause. The working command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3vectors create-index &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--vector-bucket-name&lt;/span&gt; &amp;lt;VECTOR_BUCKET&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--index-name&lt;/span&gt; &amp;lt;INDEX_NAME&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--data-type&lt;/span&gt; float32 &lt;span class="nt"&gt;--dimension&lt;/span&gt; 1024 &lt;span class="nt"&gt;--distance-metric&lt;/span&gt; cosine &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--metadata-configuration&lt;/span&gt; &lt;span class="s1"&gt;'{"nonFilterableMetadataKeys":["AMAZON_BEDROCK_TEXT","AMAZON_BEDROCK_METADATA"]}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the one that best captures why current docs matter. S3 Vectors launched in 2025, so the requirement isn't in most models' training data. A toolkit-less agent would most likely create the index, &lt;em&gt;think it succeeded&lt;/em&gt;, and only hit the wall at ingestion time, then burn an afternoon recreating it with the wrong config. The dimension (1024) and distance metric here aren't arbitrary either: they have to match the Titan embedding model, which is the kind of cross-resource constraint an agent gets wrong when it's guessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rest fell into place, and it works
&lt;/h2&gt;

&lt;p&gt;With those two out of the way, the validated sequence ran clean: create the IAM service role (trust &lt;code&gt;bedrock.amazonaws.com&lt;/code&gt; with confused-deputy conditions, so another customer can't trick the role into acting on their resources, plus least-privilege permissions to invoke Titan, read the bucket, and use the vector index), create the Knowledge Base, attach the S3 data source with fixed-size chunking (300 tokens, 20% overlap), and run ingestion. Result: 10/10 documents indexed, zero failures.&lt;/p&gt;

&lt;p&gt;The proof is a retrieval query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws bedrock-agent-runtime retrieve &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--knowledge-base-id&lt;/span&gt; &amp;lt;KB_ID&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--retrieval-query&lt;/span&gt; &lt;span class="s1"&gt;'{"text":"Is the Curl Cream safe for color-treated hair?"}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Top hit came back at &lt;strong&gt;0.86 similarity&lt;/strong&gt;, on the exact product doc with the right answer. The library is stocked.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it bought me, and what I'd do differently
&lt;/h2&gt;

&lt;p&gt;Strip away the demo and the toolkit changed two things: it handed the agent the validated setup &lt;em&gt;order&lt;/em&gt; up front (no trial-and-error), and it caught two mistakes a model trained months ago wouldn't know, because it checks current docs and ships procedures AWS maintains. AWS reports developers see fewer iterations and errors with it; on this build, the two catches alone saved me an afternoon.&lt;/p&gt;

&lt;p&gt;Two honest gaps. First, the toolkit's own rules recommend infrastructure-as-code over direct CLI, and I didn't follow that. I ran CLI calls and tracked them in a tagged manifest for teardown. It works, but CDK or CloudFormation would be the reproducible artifact a reader could clone. Second, I left the IAM role's trust policy scoped to &lt;code&gt;knowledge-base/*&lt;/code&gt; instead of the specific KB id; tightening that &lt;code&gt;aws:SourceArn&lt;/code&gt; is the obvious hardening step before this is anything but a demo.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;This is the retrieval foundation, not the whole app. Two concrete next steps, and you could take either:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Close the loop.&lt;/strong&gt; Wire a LangGraph agent to call this Knowledge Base as a tool, so it retrieves &lt;em&gt;and&lt;/em&gt; generates grounded answers. That's when "RAG knowledge base" graduates to "RAG application."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make it reproducible.&lt;/strong&gt; Convert the ad-hoc CLI provisioning into CDK or CloudFormation, so the whole stack stands up and tears down with one command, the way the toolkit's own rules recommend.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you take one thing: the toolkit's real value isn't typing commands for you, it's making better decisions, grounded in current docs, on the things an AI agent gets wrong in ways you don't notice until an hour later.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ai</category>
      <category>agentskills</category>
      <category>bedrock</category>
    </item>
  </channel>
</rss>
