AI · AIC-66

AI Harness Engineering

AI Harness Engineering is an advanced course in using coding agents to build an AI agent runtime in async Python, covering an agent loop with step and token limits, a tool layer, hooks, middleware, context engineering, subagents, sandboxing and checkpoints. It suits AI engineers, backend engineers and tech leads who already use AI to help write code.

Updated
From 4,410 THB / person 4,900 −10% excl. VAT 7% · group rates available
PDFDownload the course outline
  • Duration12 hours · 2 days
  • FormatOnsite / live online
  • Next roundOn request
  • LevelAdvanced

Course overview

When an AI agent has to work through dozens of steps, call real tools, edit real files and run commands on real systems, what makes it trustworthy is not the model alone but the harness, the runtime wrapped around the model. That means a loop that knows when to stop, tools whose errors are clear enough for the agent to correct itself, policies enforced in code rather than requested in a prompt, and context management that keeps the agent from degrading as the work gets longer.

This course takes engineers who already use AI to write code and moves them from AI user to system builder. Learners dissect commercial coding agents to see how a harness differs from a framework, then write specs for each part precisely enough for a coding agent such as Claude Code or Cursor to implement: an agent loop with step and token ceilings, the tool layer, hooks and middleware, context engineering, subagents, and sandboxing with checkpoints for long-running work. Along the way they practice reading AI-written code to find design flaws that tests miss, and they finish with a capstone on a real repository where they must justify architecture decisions that go against the agent's suggestions. (2 days, 6 hours per day, 12 hours in total, Advanced level.)

What you’ll gain

  • Write specs for agent runtime components precise enough for a coding agent to implement correctly
  • Spot design flaws in AI-written code that ordinary tests do not catch
  • Build and control an agent loop with step and token ceilings and clear stop conditions
  • Design tool interfaces and error surfaces that let the agent correct its own mistakes
  • Use hooks and middleware to enforce policy deterministically instead of relying on prompts
  • Manage context with compaction, tool-result clearing and external memory, with measurable trade-offs
  • Use sandboxing and checkpoints so long-running agents can recover from failure
  • Justify architecture decisions and evaluate or adapt Agent SDK components

Who this course is for

  • AI engineers who want to move from using AI to building agent systems
  • Backend engineers who need to connect agents to real systems and tools
  • Tech leads who choose the agent architecture for their team
  • Architects who review AI-written work at the design level
  • Platform engineers who operate and maintain agents running in the organisation

Prerequisites

  • Has already used AI chat or a coding agent to write code; this course is not for people looking for no-code tools
  • Writes Python fluently and understands async / await in Python 3.12
  • Basic working knowledge of Git, the command line and Docker
  • A coding agent account (Claude Code or Cursor) and an LLM API key with credit

Curriculum

Course Details

A 2-day course, 6 hours per day (12 hours in total, 09:00-16:00), alternating lectures with workshops in which learners write specs and have a coding agent build each part of the harness, one on top of the other, until the system is complete. Advanced level. Learners must be able to write async Python and should already have used AI to help write code. Every

workshop runs on the learner's own machine with Docker. Learners bring their own coding agent account and an LLM API key with credit; API usage is billed by actual use. Anyone who wants a foundation in using agents across software development first should take the AI Coding Agent for SDLC course. Learners take home a lab guide, sample spec files, and the harness source code for every workshop.

Day 1 Runtime Core: Loop, Tools and Hooks

Section 1: Anatomy of a Harness

  • How a harness differs from a framework, and who owns the control flow

  • The components of an agentic AI system: model, loop, tools, context and policy

  • Dissecting commercial coding agents to see what each part does

  • Configuring the Claude Code and Cursor setups used in class to work from specs

Section 2: The Agent Loop

  • The observe, decide, act and verify cycle of an agent

  • Setting step budgets and token budgets per task

  • Stop conditions and detecting loops that never finish

  • Structured tracing so you can replay what the agent decided at each turn

Section 3: Workshop: Building the Agent Loop from a Spec

  • Write a loop spec with explicit step and token ceilings

  • Define the stop conditions and the trace format you need

  • Have a coding agent implement the loop in async Python

  • Review the result, find design flaws the tests miss, and direct the fixes

Section 4: The Tool Layer

  • Tool descriptions are part of the prompt and must be designed deliberately

  • Schemas precise enough that the model never has to guess parameters

  • Error surfaces that state the cause and the fix so the agent can self-correct

  • Idempotency for side-effect tools, and truncating oversized results before they return to the context

Section 5: Workshop: File Read, File Edit and Run Command Tools

  • Write specs for file read, file edit and run command tools

  • Design error messages the agent can act on

  • Have the coding agent build the tools and wire them into the loop from the first workshop

  • Test failure cases and very large outputs

Section 6: Hooks and Middleware

  • Policy belongs in the runtime, not in the prompt

  • Deterministic lifecycle hooks that run before and after tool calls

  • Ordering a middleware chain and what changes when the order changes

  • Workshop: have the coding agent build a middleware chain from a spec without touching the loop code

Day 2 Context Engineering and Recovery

Section 7: Context Engineering

  • Why long-running agents gradually degrade

  • Tool-result clearing: removing old results that are no longer needed

  • Compaction: condensing history into structured blocks

  • External memory that survives a context reset

  • Why all three are needed together, and how to measure the trade-offs

Section 8: Workshop: Implementing Context Engineering

  • Write specs for tool-result clearing, compaction and external memory

  • Have the coding agent build all three and connect them to the harness

  • Measure before and after with traces, both token counts and task quality

Section 9: Subagents and Context Isolation

  • Isolating the context of each subagent

  • Short return contracts with pointers to the full details

  • The risks when each part reduces context on its own without coordination

  • Deciding when to split work into subagents and when not to

Section 10: Sandboxing and Recovery

  • Limiting filesystem, network and process access with Docker

  • Retries that do not repeat work that already succeeded

  • Checkpoint and resume with SQLite for long-running tasks

  • Cost caps and kill switches when an agent exceeds its limits

  • Exporting traces with OpenTelemetry to follow failed runs

Section 11: Agent SDK Scope and Moving to Other Domains

  • Comparing an Agent SDK with a custom-built harness

  • Criteria for extending what exists versus rebuilding

  • Evaluating and adapting Agent SDK components

  • Carrying the knowledge to customer service, data and RAG agents

Section 12: Capstone: A Coding Agent on a Real Repository

  • Use the harness and a coding agent on a real repository

  • Review the agent's work from an architectural point of view

  • Present three decisions that contradict the agent's suggestions, with reasons

  • Summarise how to bring the harness into the team's own work

Schedule & training options

For individuals — public rounds

No public rounds are open right now. Join the waiting list and we will contact you first when the next round opens, or ask us on LINE. Or call 02-570-8449 or 088-807-9770

For organisations — in-house / private

  • Tailor the content to your team’s tools and projects
  • Your dates, at your office or live online
  • Quotation with tax ID for procurement
Corporate training quote

Instructors

Frequently asked questions

What is an agent harness, and how does it differ from an agent framework?

A harness is the runtime that wraps the model and makes an agent actually work: the loop that calls the model repeatedly, the tool layer that lets it act, context management and the policies that keep it safe. The key difference is who controls the flow. With a framework you write code to its structure and it calls your code; with your own harness you control every decision, such as when to stop, how to trim context and which tools must pass a policy check.

How do you stop an agent loop from running forever or overspending tokens?

Set per-task ceilings on both steps and tokens and check them before every model call. Define clear stop conditions, such as the model answering without calling a tool or a ceiling being reached, and detect loops, such as the same tool being called with the same arguments several times in a row. When a ceiling stops the run, return a status that explains why, and record a structured trace each turn so you can see what the agent decided.

What is the difference between context compaction and tool-result clearing?

Both tackle long-running agents whose context fills up and whose quality drops. Tool-result clearing removes or shortens old tool outputs that are no longer needed, such as file contents read earlier, while keeping the main conversation. Compaction summarises the whole history into a short structured block and continues from that summary. Both are usually combined with external memory that keeps key facts outside the context, and you should measure token use and task quality before and after.

Who is the AI Harness Engineering course for, and what should I know beforehand?

It suits AI engineers moving from using AI to building agent systems, backend engineers connecting agents to real systems, and tech leads or architects who choose and review agent architecture. You need fluent Python with a good grasp of async/await in Python 3.12, basic Git, command line and Docker skills, and prior experience of using AI chat or a coding agent to write code. It is not for people looking for no-code tools.

What will I be able to do after the AI Harness Engineering course?

You will be able to write specs that coding agents can implement correctly, spot design flaws in AI-written code, build an agent loop with step and token ceilings, design tools and error messages that let the agent correct itself, enforce policy with hooks and middleware, manage context with compaction and external memory, and use sandboxing and checkpoints so long-running work can recover. Participants who complete the training receive a Certificate of Completion with its own number, which can be verified online.

What do I need to bring to the AI Harness Engineering course?

Bring a coding agent account such as Claude Code or Cursor, an LLM API key with credit, and a machine that can run Docker, as every workshop runs on your own computer. You write specs and have the coding agent build each part of the harness until the system is complete, and you take home the lab guide, sample specs and the harness source code.