Skip to content
YC Root AccessYC Root Access

Advanced Context Engineering for Agents

Dexter Horthy, founder of Human Layer, shares what his team has learned about scaling coding agents in real-world software projects. He walks through why naive back-and-forth prompting fails, how spec-first development keeps teams aligned, and why “everything is context engineering.” From compaction strategies to subagents and planning workflows, he shows how intentional context management turns AI coding from prototypes into production. Chapters: 00:09 - The Origin of Context Engineering 00:46 - Key Talks and Insights from AI Engineering 01:45 - Challenges with AI in Complex Systems 03:12 - The Shift to Spec-First Development 04:03 - Advanced Context Engineering for Coding Agents 04:48 - Intentional Compassion in Context Management 05:45 - Optimizing Context Utilization 07:27 - The Role of Subagents in Context Control 08:48 - Frequent Intentional Compaction 11:00 - Practical Implementation and Workflow 11:12 - Case Study: Fixing a Rust Code Base 11:59 - Insights on Effective Coding Practices 12:44 - Reviewing Features, Research, and Plans 13:30 - Conclusion and Future Directions

Dexter Horthyhost
Aug 25, 202514mWatch on YouTube ↗

CHAPTERS

  1. 0:00 – 0:30

    Where “Context Engineering” came from: Twelve-Factor Agents to the new label

    Dexter Horthy introduces himself and traces the origin of the term “context engineering” back to early work on reliable LLM applications. He positions the talk as a continuation: what comes after basic agent-building patterns.

    • Origin story: Twelve-Factor Agents manifesto and renaming the talk to “Context Engineering”
    • Why the term matters: framing reliability work as context-driven engineering
    • Setting up the talk’s goal: what’s “next” after initial agent best practices
  2. 0:30 – 1:31

    Why “vibe coding” fails: specs become the durable artifact

    Dexter cites influential talks arguing that conversational prompt sessions are ephemeral, while specifications should become the persistent source of truth. He connects this to how software practice changes when AI writes more of the implementation.

    • Sean Grove’s “The New Code”: throwing away prompts is like throwing away source code and keeping only a compiled artifact
    • In AI-heavy development, specs/intent become the critical long-lived asset
    • Shift in emphasis from “writing code” to “describing software precisely”
  3. 1:31 – 2:32

    AI in complex & brownfield systems: rework, slop, and slowdowns

    He summarizes research and field observations that agent assistance often causes rework and struggles in existing large codebases. The chapter frames the central problem: how to make today’s models effective in real-world repos.

    • Stanford study: AI coding can increase rework and waste gains
    • Breakdown cases: complex tasks, legacy/brownfield codebases
    • Founder anecdotes: agents are OK for prototypes, weak for production in big repos
    • Motivation: context engineering as the path to better outcomes with current models
  4. 2:32 – 3:32

    Forced into spec-first: surviving 2,000-line PRs and aligning the team

    Dexter explains a practical forcing function: massive AI-generated PRs that are impossible to review line-by-line. The team adopted spec-first development to maintain shared understanding and ship safely.

    • High-volume AI coder generates large complex-system PRs that are hard to review
    • Spec-first becomes necessary for alignment and reviewability
    • Dex changes behavior: read tests and specs, not every line of code
    • Outcome: after weeks of discomfort, velocity and confidence improve
  5. 3:32 – 4:02

    Advanced context engineering goals: correctness in big repos (and spend the tokens)

    He lists the operational goals they optimized for: production-quality work in complex codebases with minimal slop and strong shared context. He also acknowledges the pragmatic reality: using many tokens is acceptable if it saves engineering time.

    • Goals: works in large/complex repos, solves complex problems, no slop, team alignment
    • Token spend as a lever: invest tokens to reduce human time and rework
    • Framing: “Advanced Context Engineering for Coding Agents”
  6. 4:02 – 5:02

    Naive loop vs. “Intentional Compaction”: when to restart and what to persist

    Dexter critiques the common approach of arguing with an agent until the context window collapses, then restarting. He proposes “Intentional Compaction”: deliberately persisting only high-value progress to files/memory so new sessions/agents can pick up cleanly.

    • Naive pattern: back-and-forth steering until failure; then restart with tweaks
    • Heuristic: certain failure modes signal it’s time to reset context
    • Intentional Compaction: write a structured progress file instead of relying on /compact
    • Objective: preserve signal, drop noise, and onboard the next agent efficiently
  7. 5:02 – 6:34

    What fills the context window: noise sources and why context is everything

    He breaks down what consumes context in coding agents—searching, reading, tool outputs, and large JSON blobs—and why that degrades performance. The chapter formalizes context quality: bad info is worse than missing info, and both are worse than mere verbosity.

    • Context costs: file discovery, flow comprehension, edits, tool results (esp. large JSON)
    • LLMs as “pure functions”: output quality depends heavily on input context
    • Optimization targets: correctness, completeness, size, (and trajectory)
    • Worst-to-best: bad info > missing info > too much noise
  8. 6:34 – 7:05

    Token-budget intuition: why less “work tokens” can mean better results

    Dexter references Sourcegraph’s Jeff Hunley and the idea that within a fixed context window, the more you spend on exploration and churn, the less remains for high-quality reasoning and execution. He also notes “looping prompts overnight” can be smart when it’s designed around context constraints.

    • Heuristic equation: fixed window; minimize tokens wasted “doing work” inside the window
    • Jeff Hunley / “Ralph Wiggum as a software engineer” as a case study
    • Overnight looping can be effective if it’s aligned with how context windows behave
  9. 7:05 – 8:36

    Subagents as context control: offloading search & summarization safely

    He reframes subagents not as role-played teammates but as a tool to manage context boundaries. Subagents can do repo search and targeted reading, returning a compact summary so the parent agent stays focused and unbloated.

    • Subagents’ real value: context control and isolation
    • Common use: locate where behavior lives and trace data flow across components
    • Parent delegates reading/search; subagent returns concise, relevant findings
    • Challenge: “telephone game” prompting—ensuring subagent responses are reliable and structured
  10. 8:36 – 9:07

    Frequent intentional compaction workflow: keep context under ~40%

    Dexter presents the team’s daily operating system: frequent resets with structured artifacts to maintain a low context utilization target. The workflow is organized into three phases—research, plan, implement—with compaction between phases to preserve clarity and direction.

    • Principle: build the whole dev workflow around context management
    • Operational target: keep context utilization under ~40%
    • Three phases: research → plan → implement
    • Compaction cycle: update artifacts, mark progress, start fresh context for the next step
  11. 9:07 – 10:08

    Research and planning artifacts: file/line anchors and explicit verification steps

    He describes the concrete outputs of the research and planning prompts: precise file paths and line numbers, plus a detailed plan that enumerates changes and tests. Good plans reduce “shouting at the model” during implementation.

    • Research output: map the system with filenames + line numbers to avoid re-searching
    • Planning output: enumerate intended changes by file + snippets; include tests/verification
    • Implementation becomes smoother when plans are strong; errors trace back to weak planning
    • Prompts and templates are shared/open-sourced for reuse
  12. 10:08 – 11:08

    Human review is mandatory: replace unreadable PRs with readable specs

    Dexter argues the workflow is not magical and requires disciplined human reading—just at a higher abstraction level. He reframes code review’s core purpose as mental alignment and shows how reviewing research/plans achieves that more efficiently than reviewing huge diffs.

    • “You have to read this”: intentional human gates prevent compounding mistakes
    • Code review’s key function: mental alignment about how/why the system changes
    • Review plans (hundreds of lines) instead of PRs (thousands of lines) to catch issues earlier
    • Linear workflow integrates review of research and plans before implementation
  13. 11:08 – 12:39

    Proof in practice: one-shotting a massive Rust repo fix and shipping complex features fast

    He shares two demonstrations: a podcast experiment that produced a merged PR in a 300k-line Rust codebase, and a long session shipping tens of thousands of lines including complex capabilities. The takeaway is a hierarchy of leverage: research errors are most expensive, then plan errors, then code errors.

    • Case study: 300k-line Rust repo fix—PR merged quickly, validating “brownfield” viability
    • Complex build: multi-hour session shipping ~35k LOC with significant scope
    • Leverage hierarchy: bad research → thousands of bad lines; bad plan → hundreds; bad code → localized
    • Focus effort upstream: understand system + specify intent to prevent cascaded waste
  14. 12:39 – 14:37

    Results, adoption, and what’s next: workflow transformation over tools

    Dexter closes with outcomes (token spend, team throughput, onboarding speed) and predicts tooling commoditization. The durable advantage will be changing team communication and process around specs, context, and review rituals.

    • Measured outcomes: heavy token usage but large time savings; rapid intern productivity
    • Personal shift: largely reading specs/tests rather than code files directly
    • Prediction: coding agents commoditize; the hard part is org/workflow change
    • Call to action: adopt these practices or struggle; mentions event and resources

Get more out of YouTube videos.

High quality summaries for YouTube videos. Accurate transcripts to search & find moments. Powered by ChatGPT & Claude AI.