Skip to content

CS224N Lecture 10: Six Components of RAG and Language Agents

Aug 22, 2026 1 min
TL;DR Lecture 10 moves from question answering and RAG into language agents, then decomposes them into reasoning and planning, memory, tools, data, and evaluation. An agent is an inspectable loop between a model and external state.
Table of Contents
  1. RAG moves the knowledge source outside the model
  2. An agent is a loop between model and environment
  3. Reasoning, planning, and memory
  4. Tool use, data, and evaluation
  5. From closed-book to retrieval-augmented QA
  6. Sparse, dense, and reranked retrieval
  7. Context construction and grounded generation
  8. Layered RAG evaluation
  9. The agent loop as a state machine
  10. Observable reasoning and planning
  11. Memory needs write, retrieve, and forget policies
  12. Tool permissions and recovery
  13. Agent data and trajectory learning
  14. An agent evaluation suite
  15. A minimal verifiable agent
  16. Material gap
  17. References

🌏 中文版

The official CS224N Winter 2026 schedule places lecture 10 on February 5, 2026, but does not name a lecturer; this article therefore attributes it only to the course staff. The official deck is titled RAG and Language Agents. Its agenda closes adapters, then covers question answering and RAG, language agents, reasoning and planning, memory, tool use, and agent data and evaluation.

RAG moves the knowledge source outside the model

Answering only from parameters is limited by training time and capacity and makes specific evidence difficult to identify. RAG retrieves documents for a question and places results into the generation context. A typical pipeline contains an index, retriever, context construction, and generator.

Failure can occur at every layer: the corpus lacks the answer, chunking breaks meaning, retrieval ranks poorly, long context dilutes evidence, or generation ignores retrieved material. Evaluation therefore cannot inspect only final answers; it should at least separate retrieval recall from whether the answer is supported by evidence.

An agent is a loop between model and environment

A language agent does more than generate text once. It reads an observation, maintains state, chooses an action, calls a tool, and returns the result to the next step. ReAct, which interleaves reasoning traces and actions, is the deck's representative bridge between reasoning and acting.

This view avoids treating an agent as a mysterious new model. The underlying model may be unchanged; the differences lie in action space, tool schemas, state management, stopping rules, and error handling.

Reasoning, planning, and memory

Planning decomposes a long goal and revises steps after new observations. A complete up-front plan may continue after its assumptions fail; stepwise planning adapts but adds model calls and opportunities for cumulative error.

Memory includes short-term trajectory state and long-term information retrieved across tasks. Replaying all history into a prompt is not robust memory: it raises cost, mixes stale information, and complicates sensitive-data control. Useful memory needs write criteria, retrieval, and deletion policies.

Tool use, data, and evaluation

Toolformer represents one approach to learning when to call tools. Tools translate textual intent into API or environment actions; reliability depends on argument schemas, permission boundaries, result validation, and recovery. Actions with external side effects need approval boundaries, not only a prompt asking the model to be careful.

Agent data includes observations, thoughts/actions, tool results, and outcomes across a trajectory. Evaluation can measure task success, steps, tool errors, cost, latency, and safety violations. Success alone conflates accidental, circuitous completion with a stable method.

From closed-book to retrieval-augmented QA

RAG depends first on corpus coverage. Choose chunking from evidence spans, preserve metadata, and enforce permissions before retrieval content reaches a prompt.

Sparse, dense, and reranked retrieval

Sparse methods excel at exact terms; dense methods bridge paraphrases; hybrid systems combine them. Bi-encoders retrieve efficiently and cross-encoders rerank. Audit hard negatives for false negatives.

Context construction and grounded generation

Deduplicate, order, delimit, and cite evidence. Treat retrieved instructions as untrusted data. Verify that citations support claims, evaluate abstention, and test evidence position rather than assuming larger top-k helps.

Layered RAG evaluation

Separate retrieval recall/ranking, answer correctness, faithfulness/citations, and operational cost. Classify missing-corpus, missed-retrieval, ignored-evidence, and reasoning failures.

The agent loop as a state machine

Define state, policy action, environment observation, and termination. Validate typed actions, budget loops, and return recoverable tool errors. Side effects need idempotency and approval.

Observable reasoning and planning

Plan-and-execute, ReAct, and search expose different control flows. Evaluate action preconditions, observations, and replanning under environment feedback rather than prose-plan quality alone.

Memory needs write, retrieve, and forget policies

Separate working, episodic, and semantic memory. Add provenance, confidence, privacy, expiry, correction, and poisoning defenses; replaying all chat history is not memory design.

Tool permissions and recovery

Start read-only, grant least privilege, structure success/error/retry state, and check transactions before retrying writes. Retrieved text cannot elevate authority.

Agent data and trajectory learning

Store versioned observations, actions, tool results, and outcomes. Include recovery, not only success, and use step-level or counterfactual evidence for credit assignment.

An agent evaluation suite

Measure components, trajectories, outcomes, and operations. Perturb timeouts, schemas, malicious documents, and permissions; report variation, tail steps/cost, and human interventions.

A minimal verifiable agent

Answer from three local documents using only search and open, a five-step budget, and citations. Test answerable, unanswerable, conflicting, and malicious-document cases before any side-effect tool.

Material gap

Winter 2026 recordings are not public. This article covers the adapter recap and all six formal agenda topics without reconstructing live demos or spoken cases. The safety-boundary discussion is an engineering implication of the architecture, not presented as an experimental result from the slides.

References