AI Infrastructure & Runtime

RAG vs Context Engineering: What an AI Employee Should See per Run

Retrieval is one input among many. Context engineering decides what is assembled for each run, how big each piece may be, and what gets dropped as the run goes on.

By Hitank Shah • 5 min read • Updated 2026-11-30

Direct Answer (Quick Summary)

RAG vs context engineering is a part-versus-whole distinction. RAG retrieves passages similar to the task and inserts them into the prompt. Context engineering decides everything a run sees: instructions, rules, goal and done checks, tools, retrieved knowledge, memory, earlier results and files, how large each piece may be, and what is cleared or summarised as the run continues.

Key Takeaways

  • RAG answers which documents are relevant; context engineering answers what this run should see at all.
  • Rules that must always apply belong in instructions or policy, never behind a similarity search that might miss them.
  • Live state belongs behind a tool call at run time, because a retrieved number is only as fresh as the last time it was indexed.
  • Every context source needs a size cap, or the largest one quietly crowds out the rest.
  • Scope comes before relevance: a document from another project should be invisible, not merely ranked low.

Teams usually meet the RAG vs context engineering question the same way: retrieval is working, the right documents come back, and the employee still gets the answer wrong. The reason is that retrieval decided one slice of what the model saw. Something else decided the rest, usually by accident. Context engineering is making that something else deliberate. This article sets out the difference, then shows the per-run assembly we use in OneCo, with its actual limits.

RAG vs context engineering in one table

Retrieval-augmented generation was introduced in a 2020 paper by Lewis et al. as a way to pair a model with a searchable document index. The idea held up. What changed is that an AI employee now runs for many steps, calls tools, and acts on the result, so "which passages are relevant" is no longer the only question about its input.

RAGContext engineering
Question it answersWhich stored passages are most similar to this task?What should this run see, in what amount, and for how long?
Inputs it managesDocument chunksInstructions, rules, goal and checks, tools, knowledge, memory, earlier results, files, conversation
When it actsOnce, before the model startsBefore the run and throughout it
Typical failureThe right passage was not retrievedThe right passage was retrieved and crowded out, stale, or out of scope

Anthropic's engineering team wrote a useful general treatment, Effective context engineering for AI agents. What follows is the concrete version: what one product actually assembles.

What OneCo assembles for each run

When an employee starts a task, its instructions are built from several sources, each with a cap:

  • Its role and layer. Executive, reasoning or memory, with a one-line statement of what that layer does.
  • Its own instructions and skills. Skills come from SKILL.md files and are included when assigned to the employee.
  • The outcome and its "Done when" checks, so the employee knows what finished means.
  • Tools scoped to this employee. Only connectors the employee was granted, narrowed again for the task.
  • Knowledge, retrieved. The eight most relevant chunks, each cut at 800 characters, drawn from company-wide knowledge plus this run's own project, never another project's. A document with explicit grants is visible only to its grantees.
  • Past memory, retrieved. The five most relevant summaries of earlier runs, each cut at 500 characters.
  • The project brief, if the project keeps one: a running summary of what earlier runs in the project found.
  • Earlier results from teammates, when this task depends on them, each capped at 12,000 characters.
  • Attached files, placed in the run's workspace, with their text in the prompt up to a limit and images passed to models that accept them.

That is context assembly. Retrieval is two lines of it.

Context engineering continues during the run

A run that calls twenty tools accumulates twenty results. Without management, the conversation grows until it hits the model's limit or until early, decisive facts are buried. Three mechanisms handle this in OneCo:

  1. A cap on each tool result. A single result is cut at 10,000 characters, so one huge page cannot take over the window.
  2. Clearing old results. Tool results older than the last few tool-calling turns are replaced by a short stub naming the tool, whether it succeeded, its size, and how to get it again. A cleared write says it already ran and must not be repeated.
  3. Compaction as a last resort. If the conversation still nears its budget, the middle turns are summarised in one capped model call. The first message, the most recent turns, and anything the person typed during the run are kept word for word. If the summary fails, nothing is changed.

None of this is retrieval, and all of it decides what the model sees on step fifteen.

Where to put each kind of information

The practical skill is routing each fact to the right channel. A rough guide:

InformationPut it inWhy
A rule that must always hold ("never quote a discount over 10%")Employee instructions, and a policy if it gates an actionRetrieval might miss it; a policy is checked before the action regardless
A procedure ("how we prepare a renewal pack")A skillLoaded whole when assigned, versioned, reusable
Reference material (contracts, product docs)Knowledge, in the right projectLarge, mostly irrelevant to any one task, ideal for retrieval
Live numbers (balances, open tickets, stock)A tool call during the runOnly true at the moment of reading
What happened last timeMemory, the project brief, or a schedule's threadContinuity across runs

The most common mistake is putting a rule into knowledge. It works in testing, because the test task resembles the rule's wording, and fails in production when a task phrased differently does not retrieve it. Policy design is covered in how to build policies for AI employees.

A worked example in OneCo

Say an employee prepares renewal summaries for one client account.

  1. Knowledge page: upload the client's contract and last year's renewal notes into the client's project, not company-wide, so other projects cannot see them.
  2. Skills page: add a skill describing your renewal summary format, and assign it to the employee.
  3. Employee instructions: write the two rules that must never be broken, such as who may be named in a summary.
  4. Integrations: connect the CRM through its MCP server so current deal values are read live rather than from an old export.
  5. Give the goal with a "Done when" line like file_present: outputs/renewal-summary.md and start the run.
  6. If the answer is wrong, debug the context, not the model. Was the contract in this project or another? Did the deal value come from a tool call or from a remembered summary? Was the rule in instructions or only in a document?

The sequence of those questions is the point. How AI employees access company knowledge covers the retrieval side in depth, and knowledge systems for AI employees covers how to organise what you upload.

Trade-offs worth knowing

Caps lose information. An 800-character chunk limit means a long clause can be cut mid-sentence, so documents with dense, long paragraphs retrieve worse than well-structured ones. The fix is usually editing the document, not raising the cap.

Clearing old tool results saves tokens and occasionally forces a re-read. We accept that: a re-read costs one tool call, while an overfull window degrades every remaining step.

Memory can also go stale. A summary from three months ago may describe a process you have since changed, which is why we keep memory distinct from governed knowledge; the sibling piece on memory vs knowledge explains the split, and AI employees and persistent context covers how continuity is meant to work.

The short version

RAG is a good answer to "which of our documents matter here". Context engineering is the larger job of deciding, per run and per step, what the employee sees, with every source bounded and scoped. Get the scope and the routing right first; tune retrieval second. As why context matters for AI employees puts it, context is the actual input to the decision.

Frequently Asked Questions

Is context engineering just a new name for prompt engineering?

No. Prompt engineering is mostly about the wording of instructions. Context engineering is about which sources feed a run, how large each may be, how they are scoped, and what is removed as the run grows. The wording of the instructions is one input among several.

Should we raise retrieval limits when answers are wrong?

Usually not first. Check whether the document was in scope for that run, whether the fact should have come from a live tool call, and whether a rule was stored as knowledge instead of instructions. Raising limits adds noise and cost before it adds accuracy.

Does an employee see knowledge from every project in the workspace?

Not in OneCo. A run sees company-wide knowledge plus knowledge from its own project only, and documents with explicit grants are visible only to the grantees. A run with no project sees company-wide knowledge alone.

Related reading