Skip to main content
AIMay 21, 20267 min

What Is an Agent Harness? The Architecture That Makes AI Agents Actually Work (2026)

An agent harness is the operational layer wrapping an LLM, connecting it to tools, memory, planning loops, sandboxes, orchestration, and output channels — the architecture that turns an LLM from a passive chatbot into a real working agent. This covers the definition, 5-layer architecture, examples across Antigravity / Claude Code / OpenAI Agents SDK / LangChain, the build-vs-buy decision, and what Thai developers should know.

Agent Harness คืออะไร โครงสร้าง AI Agent 2026 - CherCode

Quick answer: An agent harness is the operational layer wrapping an LLM, connecting it to tools, memory, planning loop, sandbox, orchestration, and output channels — the architecture that turns an LLM from a passive chatbot into a real working agent. Real-world agent quality doesn't depend only on model intelligence — it depends on how well the surrounding harness supports the model. As important as model choice.

📌 Big picture: "Why does the same Claude feel so different in Claude Code vs raw API calls?" The answer is the harness — Claude Code has the planning loop + memory + tool dispatch that Anthropic engineered; raw API is a bare LLM with no harness.

What an Agent Harness Actually Is

Before 2024, "agent" just meant "LLM that can call tools." Not enough anymore — production agents need context-window management, retry / error recovery, budget controls, output validation, cross-session persistence, parallel tool calls, sandboxing for untrusted code, and more. The full structure that makes all this work together is called an agent harness. Anyone can call an LLM API — but building a stable harness is what separates Claude Code / Antigravity-class products from demo POCs.

The 5 Architectural Layers of an Agent Harness

From a recent Preprints.org survey + Firecrawl/Parallel analyses — a harness has 5 main layers:

LayerWhat it doesExample
1. LLM reasoning coreThe actual model — Claude / GPT / Gemini / LlamaClaude Opus 4.7, Gemini 3.5 Flash
2. Gateway + SessionRoute requests, remember sessions across turns, rate-limit, authAPI gateway + session store
3. Context + MemorySeparate working / retrieved / long-term memory, manage the context windowVector DB + summary cache
4. Instructions + Tools + Agentic loopTool registry, tool dispatch, planning loop, retry, validationMCP servers, function calling
5. Triggers + OutputsStart tasks from events (webhook / schedule / chat), deliver results (email / DB / API)Cron, webhook, output channels

💡 Not every agent needs all 5 layers — a simple chatbot may only need layers 1+4. But a production agent doing long-horizon work needs every layer.

5 layer agent harness architecture: LLM core, gateway, memory, tools loop, triggers

Real-World Agent Harness Examples

Every 2026 agent product has its own harness — differing by trade-off:

  • Claude Code (Anthropic) — coding-focused harness: precise tool dispatch, sandbox scoped to the user's filesystem, a controlled planning loop, MCP support.
  • Antigravity SDK (Google) — opens up "the same agent harness Google uses in its own products" to developers. Optimized for Gemini models. Includes Managed Agents (isolated Linux env per call) + persistent state.
  • OpenAI Agents SDK — open programmatic harness — define agent behavior yourself. Includes the responses API + tool registry.
  • LangChain / LlamaIndex / CrewAI — open-source harnesses that support many providers. Orchestration layer that lets you swap LLMs.
  • Custom (self-built) — many large companies write their own harness for policy control, audit, and vendor portability.
Agent harness comparison: Claude Code, Antigravity, OpenAI Agents SDK, LangChain

Build Your Own vs Use a Framework

Critical decision for teams shipping an agent product — 3 paths:

  • Use a vendor harness (Antigravity SDK / OpenAI Agents) — fast start, high baseline quality, but locked to a vendor (Gemini or OpenAI). LLM swap is hard.
  • Use an open-source framework (LangChain / LlamaIndex / CrewAI) — vendor-neutral, swap LLMs freely, but more glue code + you operate it in production.
  • Build your own — full control over policy / audit / cost + design for your domain. But 3-6 months of dev for the base layers + ongoing maintenance — only worth it for big orgs or startups where the harness is the differentiator.

💡 Rule of thumb: if the agent is a feature of your product (e.g., chatbot in e-commerce) → vendor SDK · if the agent IS the product (e.g., an AI dev tool) → custom harness · in between → open-source framework.

Agent harness decision tree: vendor SDK vs open-source vs build custom

Why Thai Devs Should Care About Agent Harnesses

As the AI agent market grows, Thai dev teams who understand the harness have 4 advantages:

  • Evaluate agent products properly — see a slick POC and immediately ask what the harness covers (retry, eval loop, etc.). Most POCs fail in production because the harness wasn't ready.
  • Build products/features that scale — instead of just calling OpenAI/Claude raw, design a harness from day one that controls cost, retries, and validation.
  • Talk to vendors informedly — pick Antigravity vs Claude SDK vs LangChain based on harness trade-offs, not brand names.
  • Reduce vendor lock-in — know what lives in the harness (swappable) vs in the LLM (harder to change). Design for model-swap as price/quality shifts.

🎯 Want to build an agent product/feature on a harness that fits a Thai business? See Antigravity 2.0 deep-dive · Gemini 3.5 Flash specs · or AI Consulting — we help pick a harness that scales for your domain.

Thai developer benefits: evaluate, build, choose, swap

Limits + Risks to Plan For

A good harness controls these 4 risk points:

  • Runaway cost — an agentic loop without a max-iteration cap can multiply API bills 10-100×. Always set a budget alert + a hard iteration cap.
  • Tool call hallucination — agents may call non-existent tools or pass wrong-schema arguments. The harness must validate args + retry intelligently.
  • Context drift — long-horizon tasks that grow context indefinitely produce progressively worse outputs. The harness needs context compression + a memory tier.
  • Security boundary — agents running user code or accessing client systems need sandboxes + scoped permissions. Never give root-level access directly.

Frequently Asked Questions

Agent harness คืออะไรในคำสั้นๆ?

Agent harness คือ โครงสร้างซอฟต์แวร์ที่ห่อ LLM แล้วเชื่อมเข้ากับ tools, memory, planning loop, sandbox, orchestration และ output channels เปลี่ยน LLM จาก chatbot ตอบคำถามเฉยๆ → agent ที่ทำงาน multi-step ได้จริง ตัวอย่างเป็น Claude Code, Antigravity SDK, OpenAI Agents SDK, LangChain ทุกตัวคือ harness ที่ design มาคนละแบบ

Agent harness ต่างจาก agent framework ยังไง?

ใกล้กันมาก ใช้แทนกันได้บ่อย แต่ละเอียดต่างกันเล็กน้อย: framework มักหมายถึง library/SDK ที่ developer ใช้ build agent (LangChain, CrewAI) harness หมายถึงโครงสร้าง runtime ทั้งหมดที่ run agent ในการใช้งานจริง (รวม sandbox, gateway, monitoring) framework = สิ่งที่คุณเขียน harness = สิ่งที่รันโค้ดของคุณ — ในการสนทนาทั่วไปสองคำนี้แทนกันได้

ต้อง build harness เองไหม หรือใช้ของพร้อม?

ขึ้นกับว่า agent เป็น feature หรือ product — ถ้าเป็น feature (เช่น chatbot ใน e-commerce) → ใช้ vendor SDK (Antigravity / OpenAI Agents) เริ่มเร็วและไม่ต้องคุม infra ถ้าเป็น product (เช่น AI dev tool ที่แข่งกับ Claude Code) → ต้อง build เองเพราะ harness เป็น differentiator ตรงกลางๆ → open-source framework (LangChain / CrewAI) vendor-neutral

Agent harness ดีๆ ต้องมีอะไรบ้าง?

5 ชั้น: (1) LLM reasoning core ที่เลือกได้ (2) Gateway/session ที่จำ context ข้าม turn (3) Memory tier ที่แยก working/retrieved/long-term (4) Agentic loop ที่ retry/validate tool calls (5) Triggers/outputs ที่ start จาก event และส่งผลออก รวมกับ guardrail: max iteration cap, budget alert, sandbox isolation, output validation

ทำไม Claude ตัวเดียวกัน เอาใส่ Claude Code ดีกว่าเรียก API ตรงๆ?

เพราะ Claude Code มี harness ที่ Anthropic engineer มาให้ — planning loop ที่ตัดสินใจว่าจะเรียก tool ไหน, memory ของ codebase, sandbox ใน filesystem, retry logic, MCP integration เรียก API ตรงๆ = ได้ LLM เปล่าๆ ไม่มีโครงสร้างเหล่านี้ คุณต้อง build เอง ความฉลาดของโมเดลใกล้กัน — ต่างที่ harness รอบโมเดล

Vendor SDK กับ open-source framework เลือกอะไรในไทย?

ถ้าทีมเล็ก (1-5 คน) ต้องการเริ่มเร็ว → vendor SDK ลดเวลา setup จากหลายสัปดาห์เหลือไม่กี่วัน ถ้าทีมกลาง-ใหญ่ (5-50 คน) ที่ต้องการ vendor portability + คุม cost ระยะยาว → open-source framework (LangChain หรือ CrewAI) ถ้าทีมที่ build agent product เป็นธุรกิจหลัก → build harness เอง บางส่วน ใช้ framework อื่นเสริม สำหรับ chercode แนะนำเริ่มที่ vendor SDK ก่อน ถ้า scale ค่อยขยับ

Share:
Arm - CherCode

Arm - CherCode

Full-Stack Developer & Founder

Software developer with 5+ years of experience in Web Development, AI Integration, and Automation. Specializing in Next.js, React, n8n, and LLM Integration. Founder of CherCode, building systems for Thai businesses.

Portfolio

Related Service

AI Consulting Services

Learn More