← All courses ← Course home

Lesson 02 of 05

Six layers of a working harness

Name the six layers. Trusted context does most of the work. The model is a config choice in the runtime layer.

Agent brief (llms.md)

When a run goes wrong, you need a name for the layer that failed. Do not start with "the model was bad." Walk the six layers. Build the picture one step at a time.

Start with how work begins, and who runs the loop.

flowchart LR
  T[Trigger] --> O[Orchestration]
      

Trigger is the event that starts a run: a user send, a webhook, a cron, a ticket. If you cannot name the trigger, you cannot replay the job.

Orchestration is the loop. It holds memory for this run, retries, and hard limits. A state machine you own is one shape of this layer. See Run an agent with a state machine. The loop must end. A missing limit is a harness bug, not a model bug.

Now add the two layers that feed the model.

flowchart LR
  T[Trigger] --> O[Orchestration]
  O --> Tools
  O --> C[Trusted context]
      

Tools do work the model must not guess. KPI math, refunds, and lookups belong in fixed functions. The model chooses when to call them. The function owns the number.

Trusted context is the truth the model may see, plus the access rules. Pack only approved files, metrics, and memories. This layer does about 80% of the success. A clever prompt will not save a pack that is wrong, stale, or too wide. Build a context packer for on-device AI is that job on a device.

Finish with the layers that keep you honest after the call.

flowchart LR
  T[Trigger] --> O[Orchestration]
  O --> Tools
  O --> C[Trusted context]
  O --> Ctrl[Control]
  O --> R[Runtime]
      

Control is golden sets, guardrails, and approvals. A named person decides what "good" means. You will write that bar in lesson 05. Stop prompt attacks and leaks sits here on the way in and out.

Runtime is traces, cost, and audit. This is also where you pick the model. A model swap should be a config change, not a rewrite. If you cannot see the hops, you cannot improve the harness. Trace every step of an AI call is the receipt book.

Rule. Point at a layer before you blame the weights.

Next, sketch a tiny harness you can run on a CPU.

Key concepts

  • Trigger starts the run from an event you can name and replay.
  • Orchestration is the loop, memory, retries, and limits.
  • Tools hold fixed logic for KPIs and other facts the model must not invent.
  • Trusted context is truth plus access control. It does about 80% of the success.
  • Control is golden sets, guardrails, and approvals. Runtime is traces, cost, audit, and model choice as config.

Takeaways

  • Name the failed layer before you change the model.
  • Spend most of your care on trusted context and tool contracts.
  • Keep model swap as a runtime config change.