Context engineering with Dex Horthy

Summary of Context engineering with Dex Horthy

by Gergely Orosz

1h 32mJuly 15, 2026

Overview of Context engineering with Dex Horthy

In this episode, Gergely Orosz speaks with Dex Horthy, founder of HumanLayer, about how AI is changing software engineering and why the key skill is increasingly context engineering: carefully shaping the inputs, state, and workflow around LLMs so they produce reliable results. Dex shares his journey from physics and platform engineering into AI, explains the ideas behind his “12-factor agents” manifesto, and argues that the future of agentic software depends less on raw prompting and more on well-designed loops, harnesses, compaction, and human checkpoints. He also warns that fully automated “dark factories” can quickly create unmaintainable codebases if humans stop reading and steering the system.

Dex Horthy’s background and path to AI

From physics to software factories

  • Dex studied physics and initially expected to go into academia, finance, or programming.
  • A high school internship with NASA/JPL exposed him to real software problem-solving, including pathfinding for lunar rover navigation.
  • He moved into software professionally, taking an early platform engineering role at Sprout Social.

Why platform engineering mattered

  • Early in his career, he realized the most valuable work often came from the teams building:
    • CI/CD
    • sandbox environments
    • preview systems
    • internal developer platforms
  • This shaped his long-running obsession with software factories: building the systems that build the software.

Customer-facing work and product thinking

  • At Aspiration and later Replicated, he moved deeper into customer-facing and product-focused work.
  • He found he enjoyed working with customers and became the company’s first customer-facing engineer, helping close deals and eventually building a large team.
  • That experience convinced him that spending time with users and customers can improve both technical judgment and personal growth.

Context engineering: the core idea

What it means

Dex defines context engineering as the practice of optimizing everything that goes into a model’s context window so the model can produce better outputs.

  • It includes:
    • prompts
    • tool definitions
    • retrieval/RAG
    • memory
    • structured outputs
    • agent history
    • ordering of information
  • The key insight: all of these are just different ways of passing tokens into a model and shaping tokens out.

Why it matters

  • For simple demos, generic frameworks can get you far.
  • But if you need reliability, accuracy, and production readiness, you have to think at the token level:
    • what gets included
    • in what order
    • how much context is too much
    • how to compress state without losing meaning
  • Dex argues that context engineering is about moving from “good enough” to high-confidence production systems.

Why the term caught on

  • Dex says he didn’t invent the practice, but he named and clarified a pattern that many builders were already discovering.
  • The term stuck because it gave engineers a practical way to talk about the real work of making LLM apps reliable.

The 12-factor agents manifesto

Dex’s “12-factor agents” idea distilled lessons from talking to many AI builders. The main themes include:

  • Own your prompts and context window
  • Treat tools as structured outputs
  • Keep execution state and business state unified
  • Use humans as part of the toolchain
  • Make control flow explicit
  • Compact errors and noisy history
  • Keep agents small and focused
  • Design agents as stateless reducers/transducers
  • Trigger agents from real events
  • Meet users where they are
  • Prefer clear workflows over magical autonomy

The bigger lesson

Agent systems work best when they are treated less like mysterious chatbots and more like structured software pipelines with explicit inputs, outputs, and verification.

Context window “physics”: smart zone vs. dumb zone

The smart zone

  • Dex says the first part of the context window is where the model performs best.
  • He roughly treats the first 100K tokens as the “smart zone” for many tasks, sometimes more for larger frontier models.

The dumb zone

  • As context grows, quality declines:
    • more irrelevant information
    • conflicting instructions
    • harder attention over long histories
  • Once you’re deep in the context window, the model becomes more likely to:
    • drift
    • forget earlier instructions
    • make odd decisions
    • overfit to bad trajectories

Practical implication

  • Keep important instructions and state compact.
  • When the context gets noisy, start over with a fresh session and a compressed artifact rather than endlessly extending a bad trajectory.

Intentional compaction

Dex emphasizes frequent intentional compaction as a foundational technique.

What it is

  • Read or inspect a large amount of messy information.
  • Compress it into a smaller, clearer artifact:
    • a markdown summary
    • a design doc
    • a decision record
    • a state snapshot
  • Verify the compression, then start a new context window.

Why it works

  • It keeps work inside the “smart zone.”
  • It reduces drift and context noise.
  • It lets humans steer the model without carrying around enormous histories.
  • It is especially useful for:
    • research
    • design
    • implementation planning
    • debugging hard problems

Harness engineering

Definition

Harness engineering is about shaping the environment around the model rather than only the prompt itself.

This includes:

  • command structure
  • MCP/tooling
  • skills
  • repository layout
  • coding environment
  • inner harness vs. outer harness

Inner vs. outer harness

  • Inner harness: the tools and interfaces exposed to the model
  • Outer harness: the environment humans build around the model to guide its behavior

Why it matters

  • A better harness raises the floor for every turn the agent takes.
  • It makes the system more reliable without requiring the model to “understand everything.”
  • Martin Fowler’s framing of inner and outer harnesses was highlighted as a useful way to think about this space.

Loop engineering

The basic idea

Loop engineering means designing systems where agents can:

  • take an action
  • receive verification or feedback
  • improve their work
  • repeat

Why loops are powerful

  • They let models check their own work.
  • They work best when tasks are verifiable:
    • tests
    • linters
    • compilation
    • measurable performance improvements
  • If the goal can be objectively checked, an agent can iterate until it succeeds.

Dex’s favorite pattern: slow loops

Rather than “big bang” autonomous systems, Dex favors slow, contained loops:

  • run nightly
  • fix one issue at a time
  • open a small PR
  • wake up to a slightly better codebase

This is a more practical and safer version of automation than trying to let agents rewrite everything in one shot.

The warning about dark factories

What is a dark factory?

A dark factory is a fully automated system where humans are removed from the process entirely.

Why Dex is cautious

He experimented with a “lights-off software factory” and shut it down after a few months because:

  • code volume grew too fast
  • nobody was reading enough of the code
  • maintainability collapsed
  • debugging became much harder

The key risk

A system that optimizes for throughput alone can generate:

  • slop
  • architectural drift
  • brittle code
  • expensive long-term maintenance

Dex’s message is not “never use agents,” but rather:

  • don’t stop reading the code
  • keep human judgment in the loop
  • optimize for maintainability, not just speed

Software factories: pre-AI and AI era

Historical framing

Dex traces the idea of a software factory back to:

  • a NATO conference in 1968
  • later DevOps and automation practices
  • modern agentic software systems

Pre-AI software factory

Traditional software factories had:

  • work queues
  • planning
  • development
  • PR review
  • CI/testing
  • deployment
  • support feedback loops

AI software factory

AI changes the factory by replacing or augmenting more parts of the loop:

  • agents can build features
  • agents can review code
  • agents can test
  • agents can respond to support tickets
  • agents can fix bugs from monitoring alerts

Dex’s view

The software factory is changing everywhere, but at different speeds:

  • some teams are only using coding assistants
  • others are automating support-to-PR workflows
  • the most advanced teams are experimenting with more continuous agentic loops

Spec-driven development and why specs drift

The promise

Spec-driven development aims to:

  • write the spec first
  • let the model implement from the spec
  • use the spec as a source of truth

The problem

Dex argues that specs often drift from code:

  • the code changes
  • the spec becomes outdated
  • now there are two sources of truth

His conclusion

  • Specs are useful as tactical execution artifacts
  • They are less useful as long-lived, evergreen documentation unless there is a strong reason to keep them synchronized
  • In many cases, the codebase itself must remain the source of truth

Research → Plan → Implement (RPI)

The original workflow

Dex describes an early RPI pattern:

  1. Research the codebase and problem
  2. Plan the implementation
  3. Implement the change

What worked

  • Research docs helped compress large amounts of codebase understanding
  • Plans helped agents stay on task longer and avoid getting distracted
  • The structure improved completion on larger tasks

What didn’t

  • Plans were often too detailed and too expensive to review
  • They duplicated effort: reading the plan and then reading the PR
  • They became anti-leverage when they turned into another artifact that humans had to maintain

Current view

  • RPI is still useful, but only when the artifacts are short-lived and purpose-built
  • The best docs are often the ones you create fresh for the current task and discard afterward

Token harder vs. token smarter

Token harder

  • Maxing out agent usage
  • pushing as many tokens through the system as possible
  • treating throughput as the goal

Token smarter

  • Using fewer, better-placed tokens
  • keeping humans in the loop where judgment matters
  • choosing leverage points carefully
  • optimizing for maintainability and quality, not just volume

Dex’s argument:

  • Don’t just ask “how do we use more AI?”
  • Ask “where does AI give us the most leverage without degrading the system?”

HumanLayer: Dex’s current work

What it is

HumanLayer is an AI IDE / collaboration platform for building software with agents.

Core goal

Help teams build production software with AI while maintaining:

  • quality
  • control
  • collaboration
  • human oversight

Key product direction

Dex describes the future IDE as:

  • agent-first
  • collaborative
  • real-time
  • able to stream agent traces, diffs, docs, and tasks into a shared environment

Why this matters

He believes the pull request as the primary coordination unit may be too slow and too discrete for agentic software development.

Instead, HumanLayer is aiming for a workflow where:

  • humans and agents collaborate continuously
  • feedback is embedded earlier
  • work is visible in shared space
  • PRs may no longer be the central artifact

Hiring philosophy and team profile

What they look for

Dex says they want people with strong software fundamentals:

  • distributed systems
  • operating systems
  • core computer science
  • good judgment

What they can teach

They can help people get good at AI development relatively quickly.

What is hard to teach

Deep CS intuition and architectural judgment take much longer to develop.

Reading recommendations

Dex recommends revisiting classic software engineering books, especially:

  • Refactoring — Martin Fowler
  • The Pragmatic Programmer
  • Clean Code

His point: these classics are more relevant than ever because AI makes software easier to write, but not necessarily easier to maintain.

Key takeaways

  • Context engineering is the real work behind reliable AI software.
  • Context windows have limits; quality drops as noise and history accumulate.
  • Intentional compaction is essential for keeping agents effective.
  • Loops are powerful when tasks are verifiable, but they need boundaries.
  • Dark factories can create unmaintainable code if humans stop reading and steering.
  • Software factories are evolving, but the best teams will keep human judgment in the loop.
  • The future is not “no engineers,” but engineers using AI at the right leverage points.

Notable insight

“If you stop reading the code, you have about three to six months before your codebase becomes easier to rewrite than to fix.”

This captures Dex’s central warning: AI can accelerate software creation dramatically, but without human review, architectural discipline, and deliberate compaction, speed eventually turns into technical debt.