<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx" -->

---
title: Context Engineering for AI Agents Starts with Retrieval
description: Agents have a limited context window, so retrieval breaks in three ways: inefficient searching, oversized results, and irrelevant or stale context. LangChain's...
canonical: https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Context Engineering for AI Agents Starts with Retrieval | daily.dev
og:description: Agents have a limited context window, so retrieval breaks in three ways: inefficient searching, oversized results, and irrelevant or stale context. LangChain's...
og:url: https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx
og:image: https://api.daily.dev/og/posts/oR6sFDhgX.png
og:image:alt: Context Engineering for AI Agents Starts with Retrieval
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Engineering for AI Agents Starts with Retrieval

**[LangChain](https://daily.dev/sources/langchain)** · 12 min read · 0 upvotes · 0 comments

## Summary

Agents have a limited context window, so retrieval breaks in three ways: inefficient searching, oversized results, and irrelevant or stale context. LangChain's Deep Agents harness tackles this with built-in filesystem tools: glob matches file names, grep searches text without loading files, and read_file pages through content 100 lines at a time. Oversized tool results (over about 20,000 tokens) get saved to files automatically, with just a path and preview returned to the agent. For custom search tools like RAG, the post recommends a 'retrieve, offload, delegate' pattern: save results to files, return only the paths, and let subagents read and summarize them so the main agent only sees conclusions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.langchain.com/blog/context-engineering-starts-with-retrieval>

## Questions this post answers

### How do I stop my AI agent from filling its context window with search results?

Use a 'retrieve, offload, delegate' pattern: save each retrieved result to a file and return only the file path to the main agent, instead of the full content. A subagent then reads each file and returns just the key facts, so the main agent only sees short summaries rather than full documents or search dumps.

_Building agent retrieval pipelines? daily.dev surfaces context-engineering patterns like this one as they emerge._

### What's the difference between grep and semantic search for an AI agent's retrieval tool?

Grep matches exact literal text inside files without loading them into context, which is efficient when you know the exact words to search for, such as 'Company A funding'. Semantic search, backed by a vector store, matches by meaning instead, catching results like an article titled 'Company A closes $50M Series B' that grep would miss entirely.

_Choosing between exact-match and semantic search tools is easier with practical comparisons like this on daily.dev._

### What is agentic retrieval versus 2-step RAG?

2-step RAG searches once at the start and then answers, which works for simple FAQ bots but fails when new information emerges mid-task. Agentic retrieval lets the agent decide when to search, what to search for, and whether more searching is needed, running in a loop that can call any tool as many times as necessary, as implemented by default in LangChain's Deep Agents harness.

_Developers deciding how to architect agent search loops can track these RAG patterns on daily.dev._

## Similar posts on daily.dev

- [How agents can use filesystems for context engineering](https://daily.dev/posts/how-agents-can-use-filesystems-for-context-engineering-hghijxgzg) · LangChain · 1 upvotes · 0 comments
- [Retrieval vs. Memory in Agentic AI System](https://daily.dev/posts/retrieval-vs-memory-in-agentic-ai-system-w27x4mch5) · Machine Learning Mastery · 2 upvotes · 0 comments
- [An Animated Guide to RAG: How AI Finds Answers in Your Documents](https://daily.dev/posts/an-animated-guide-to-rag-how-ai-finds-answers-in-your-documents-fdfvsddsl) · Machine Learning Pills · 55 upvotes · 0 comments
- [Agentic RAG: Let the Agent Search](https://daily.dev/posts/agentic-rag-let-the-agent-search-fbdgqwlmi) · Towards Data Science · 3 upvotes · 1 comments
- [RAG vs. Long Context in 2026: When Retrieval Still Wins](https://daily.dev/posts/rag-vs-long-context-in-2026-when-retrieval-still-wins-ns3byqn4i) · Medium · 0 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#rag](https://daily.dev/tags/rag), [#langchain](https://daily.dev/tags/langchain), [#context-engineering](https://daily.dev/tags/context-engineering)

[View this post on daily.dev](https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Context Engineering for AI Agents Starts with Retrieval","url":"https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx"},"datePublished":"2026-10-23T16:59:15.345Z","dateModified":"2026-10-23T17:10:40.403Z","description":"Agents have a limited context window, so retrieval breaks in three ways: inefficient searching, oversized results, and irrelevant or stale context. LangChain's...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/39de9ae15afdd01407bcf0f489e627c6?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/39de9ae15afdd01407bcf0f489e627c6?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"LangChain","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"LangChain","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/0f4f2629e0724a849823f8cd0d913e13","url":"https://daily.dev/sources/langchain"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,rag,langchain,context-engineering","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"LangChain","item":"https://daily.dev/sources/langchain"},{"@type":"ListItem","position":3,"name":"Context Engineering for AI Agents Starts with Retrieval"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/context-engineering-for-ai-agents-starts-with-retrieval-or6sfdhgx#faq","mainEntity":[{"@type":"Question","name":"How do I stop my AI agent from filling its context window with search results?","acceptedAnswer":{"@type":"Answer","text":"Use a 'retrieve, offload, delegate' pattern: save each retrieved result to a file and return only the file path to the main agent, instead of the full content. A subagent then reads each file and returns just the key facts, so the main agent only sees short summaries rather than full documents or search dumps. Building agent retrieval pipelines? daily.dev surfaces context-engineering patterns like this one as they emerge."}},{"@type":"Question","name":"What's the difference between grep and semantic search for an AI agent's retrieval tool?","acceptedAnswer":{"@type":"Answer","text":"Grep matches exact literal text inside files without loading them into context, which is efficient when you know the exact words to search for, such as 'Company A funding'. Semantic search, backed by a vector store, matches by meaning instead, catching results like an article titled 'Company A closes $50M Series B' that grep would miss entirely. Choosing between exact-match and semantic search tools is easier with practical comparisons like this on daily.dev."}},{"@type":"Question","name":"What is agentic retrieval versus 2-step RAG?","acceptedAnswer":{"@type":"Answer","text":"2-step RAG searches once at the start and then answers, which works for simple FAQ bots but fails when new information emerges mid-task. Agentic retrieval lets the agent decide when to search, what to search for, and whether more searching is needed, running in a loop that can call any tool as many times as necessary, as implemented by default in LangChain's Deep Agents harness. Developers deciding how to architect agent search loops can track these RAG patterns on daily.dev."}}]}
```

