WhoBuilt

Architecting and Testing Controllable Agents

Oct 11, 2024· 2 h 22 min· 9.6K views·Watch on YouTube

Speaker

Lance Martin of LangChain leads a hands-on AI Engineer workshop on designing and evaluating reliable, controllable agents.

Chains, agents, and tool calling

Martin distinguishes chains, whose steps are set by developers, from agents, where an LLM chooses what happens next. In a ReAct loop, the model selects a tool, receives its result, and decides whether to act again. That flexibility can come with reliability problems, including wrong tool choices, bad arguments, and repeated calls.

Constrain control flow with LangGraph

Martin presents LangGraph as a way to combine fixed steps with LLM-directed choices at specific points. Its graphs use nodes, edges, and shared state to manage operations and information. He illustrates the approach with Corrective RAG, which grades retrieved documents and can use web search when they are irrelevant, and Self-RAG, which checks answers for hallucinations and relevance.

Evaluate answers and agent trajectories

Martin describes three feedback loops: error correction inside the app, pre-production evaluation, and production monitoring. An evaluation can combine a dataset, an application, and an evaluator, such as a heuristic or an LLM judge. He recommends checking both answer quality and tool-use trajectories, since an agent can reach a correct answer through inefficient or unexpected steps.

Build a feedback loop for improvement

Martin suggests starting with a small evaluation set, even five question-and-answer pairs, and using model-generated examples that people review. In production, teams can grade retrieval quality, answer relevance, and grounding without reference answers, then audit failures and add them to the offline test set. He also recommends simple, fast checks for in-app correction, such as testing whether generated code imports exist.

Choose retrieval and routing deliberately

Martin recommends separating retrieval chunks from the context passed to the model: retrieve with smaller chunks, then use the full document when more context is needed. For multi-turn RAG, he says a deeper follow-up may call for retrieving more content or filtering by section metadata, rather than only rewriting the question. For many tools or multiple knowledge stores, an explicit router or semantic search over tool descriptions can reduce reliance on a model choosing from a long list.

Takeaways

  • Use fixed graph steps for predictable work and reserve model decisions for places that need branching.
  • Evaluate both the final answer and the agent’s tool-use path; correctness alone can hide inefficient or erratic behavior.
  • Start with a small, reviewed evaluation set and grow it with audited production failures.
  • Put lightweight, fast checks inside the workflow to catch errors the model can correct.
  • For follow-up questions, adjust retrieval scope or metadata filters when users need deeper source context.

Mentioned in this talk

Search inside this talk

What was claimed 12

Show all 12 facts

Related talks