# The Art of Loop Engineering: How to Build Agents That Improve Over Time
<!--
ref: @content/youtube/langchain/2026-07-23-the-art-of-loop-engineering-how-to-build-agents-that-improve-over-time
version: 3
updated_at: 2026-10-31T18:12:20.481Z
-->

Sydney (LangChain, 2026-07-23): Sydney argues that a model has a fixed level of intelligence, and an agent only becomes useful through the harness built around it.

**[Watch on YouTube](https://www.youtube.com/watch?v=jPPiZ22DY3g)**


*Synthesized from Sydney on LangChain, 2026-07-23.*

Sydney is a product manager on LangChain's open-source team and a former software engineer. In this webinar she walks through four nested "loop" levels for agent harnesses, using LangChain's own internal docs-improvement agent as the running example.

## Core Thesis
Sydney argues that a model has a fixed level of intelligence, and an agent only becomes useful through the harness built around it. The strongest part of that harness is a set of composable loops: the core agent loop, a verification loop, an event-driven loop and a hill-climbing (self-improvement) loop. In her words, the advantage comes less from the agent itself than from the loops wrapped around it. Each outer loop makes the inner loops work better. Closing the outermost loop safely depends on good evals and on deliberate human-approval points.

## Key Insights
- **Loop 1: the core agent loop.** The model gets the context for a task, calls tools, gets observations back and keeps going until it decides it's done. Its power is that the model chooses both what actions to take and when to stop. Engineering at this level means three things:
  - giving the model the right tools
  - matching model intelligence to task complexity, so you can manage cost
  - prompt-engineering the tool descriptions so the model uses the tools well
- **Running example: the docs-improvement agent.** It takes a request, plans and drafts changes, clones the docs repo, reads the existing docs, writes new ones and opens a pull request with a diff and description.
- **Loop 2: the verification or `/goal` loop.** After an agent cycle returns a result, a grader scores it against rubric criteria. If the criteria aren't met, the result goes back into the agent loop. If they are, the task is done. Sydney's example: `/goal` implement a feature and don't stop until all tests pass and coverage reaches **95%**.
- **Dcode shows you its rubric.** Sydney says Dcode, LangChain's terminal coding agent built on Deep Agents, turns your goal into explicit criteria and shows them to you for review before checking against them every iteration. She says Claude Code and Codex don't offer that level of control. Because the goal/rubric middleware is open source, you can plug it into any agent built with `create_agent` or `create_deep_agent`.
- **Docs agent at loop 2.** The grader checks that all links resolve and CI passes before reporting the task done, so human reviewers don't spend time on PRs with broken links.
- **Verification loops make cheaper models workable.** They let less powerful models handle harder tasks by keeping long agent cycles on track, much as to-do lists kept early models on track.
- **Loop 3: the event-driven loop.** Sydney says this is the loop that actually gets her to use agents. Agents get triggered inside the systems where work happens (Slack, GitHub, email), and their output improves those systems. That improvement then prompts the next trigger. There are two kinds of trigger:
  - **Scheduled:** for example, a background agent that reviews her calendar every morning and summarizes what she needs to prep.
  - **Event-based:** for example, an email assistant that fires when a message arrives, then reads it, drafts a reply and decides whether it's spam or worth surfacing.
- **Docs agent at loop 3.** A Slack channel called `#docs-please` receives a request such as "add a `/goal` or `/rubric` page to the Deep Agents docs." The agent drafts a PR, the verifier checks links and CI, a Slack notification goes back asking for review, and the merged docs go live. Reading the live docs then motivates the next request.
- **The loops nest but don't have to.** Sydney draws them like Russian dolls but notes they're composable in any combination. For example, you can put an event-driven loop around a core agent loop with no verifier.
- **Loop 4: the hill-climbing (learning, self-improvement) loop.** Agents are non-deterministic, so the real story of what they did lives in traces, not code. After a run finishes, a background agent (LangSmith **Engine**) analyzes single traces or batches of them to find failure modes, such as:
  - tools called with the wrong arguments
  - critical tool calls missed because the needed context wasn't there
  - recurring user preferences that aren't being respected
- **Engine edits the harness itself.** It can update prompts, tools, skills and memory and write the changes back to the agent's source code.
- **Two kinds of loop-4 improvement:**
  - **Procedural:** tool descriptions, prompts and procedural skills that steer the agent's trajectory.
  - **Semantic memory:** facts persisted across runs. Sydney's example is an email assistant that learns to write formally to her boss and informally to coworkers after she corrects it once.
- **Loop 4 also covers efficiency.** Beyond checking that the agent did the right thing, you can ask whether its tool-call trajectory was efficient, and if not, why. Sydney says LangChain is researching this for coding agents.
- **Evals gate loop 4.** You can't confidently merge harness changes without an eval suite that shows no regressions and, ideally, improvements on some tasks.
- **What each level automates.** Loop 1 automates work. Loop 2 automates reliability through automated checks. Loop 3 automates improvements to external systems, such as your docs. Loop 4 automates improvements to the agent itself.
- **Human approval at each level.** Automation doesn't mean removing humans. It means using them only where their judgment adds value:
  1. sensitive tool calls, such as sending email or booking travel
  2. inside the grader or verifier step
  3. on workflow artifacts, such as reviewing docs PRs before merge
  4. on harness or code changes to the agent
- **A speculative "loop 5."** Sydney floats a fifth level: an RL-style learning environment proposes harness changes, runs the full eval suite, and auto-merges if a set improvement threshold is met. For most teams today, she says, changes to agent source code still need human review.
- **Two memory stores LangChain is focused on:** a repository wiki that helps coding agents navigate a codebase efficiently, and personal wikis for semantic knowledge. **OpenWiki**, built on Deep Agents, sets up that initial memory system, and loop 4 keeps it updated.
- **Graders can be scoped to subagents.** The rubric middleware attaches to the main agent loop by default, but you can attach graders to specific task-focused subagents through LangChain's composable middleware stack.
- **Latency is a tradeoff, with guardrails available.** Loops add latency, so you balance correctness, cost and latency:
  - A stronger model needs fewer grader passes.
  - A cheaper model plus more verification works if you can tolerate the extra latency.
  - Guardrails help: subagent timeouts and a maximum number of cycles before the agent returns to the user.
  - The event-driven and learning loops aren't really latency-bound. For the learning loop, the real constraint is whether you have enough data to make good harness changes.
- **Context rot is a context-engineering problem.** Compress earlier prompts and attempts in the background. When the agent re-enters a retry loop, compress the previous attempts and keep only the current artifact, the rubric criteria and the goal.
- **A verification loop is just an eval.** Sydney quotes a line she heard that week: it's "an eval in a trench coat." The only way to prove it improves production outcomes is with online evals, plus offline evals, run through the build → test → deploy → monitor cycle.
- **Two tiers of evals:**
  - baseline, unit-test-like evals that guard against regressions
  - hard, end-to-end "shoot for the stars" evals you can hill-climb on

## Actionable Takeaways
1. **Tune loop 1 first.** Pick the right tool set, match model size to task complexity for cost, and rewrite tool descriptions until the model uses the tools correctly.
2. **Add a verification loop with explicit criteria.** Use `/goal`-style rubrics with concrete thresholds, such as "all tests pass, coverage ≥95%" or "all links resolve, CI passes." In Deep Agents or LangChain agents, plug in the open-source rubric/goal middleware, and review the generated criteria before the agent starts.
3. **Ambiguous success criteria need human labels.** If your reward signal is hard to quantify, have humans annotate the criteria the agent generates. Use those labels to improve both the criteria generator and the evaluator.
4. **Wire agents into existing tools.** Use scheduled triggers (such as a daily calendar summary) or event triggers (a new email, a Slack message in a channel like `#docs-please`), and send results and approval requests back to Slack so humans never bottleneck on finding them. Fleet is the no-code route; managed Deep Agents is the code route.
5. **Trace everything, then run a post-run analyzer.** Use something like LangSmith Engine on traces to find bad tool arguments, missed tool calls, ignored preferences and inefficient trajectories. Turn the findings into prompt, tool, skill or memory updates.
6. **Change memory, skills and prompts before architecture.** Most agent failures come from missing information, not a weak model. Only add deterministic code or restructure the runtime (including LangGraph graphs) once that's tried, for example when the agent keeps skipping a required compliance step.
7. **Gate every harness change on evals.** Keep both baseline regression evals and stretch evals. LangChain's eval-engineering skill can generate evals from live traces and repo context, and it interviews you about what success means.
8. **Place human approval deliberately.** Hand approval to the person who naturally owns the decision, such as the travel agent's own user. Let the model decide when approval is actually needed (skip it for obvious spam, require it for sensitive emails). Keep human review on PRs and on agent code changes.
9. **Bound your loops.** Set subagent timeouts and maximum cycle counts. Compress earlier attempts on retries to control tokens and context rot.
10. **Version-control harness changes, and inspect agent work through trajectory views of traces.** Give tools "breadcrumbs" of the impact they had.

## Notable Quotes
> "The advantage is not just in the agent that you build to automate work, but rather in the loops that you build around it." — Sydney

> "Agents don't have that much value unless they're incredibly easy to use." — Sydney

> "The story is actually in traces for agents." — Sydney

> "This outer loop makes each inner loop more effective." — Sydney

> "This just sounds like an eval in a trench coat." — Sydney (quoting a line she'd heard that week)

> "...not necessarily cuz the model isn't powerful enough, but just cuz it doesn't have the right information." — Sydney

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*