01
Tại sao cần Harness? Agent thực sự là gì?
Ba lớp: Model lõi (LLM) → Builder harness (Anthropic/OpenAI) → User harness (đội bạn)
Reframe: mọi thất bại của agent là vấn đề cấu hình, không phải giới hạn model.
| Agent làm sai | Giải pháp harness |
|---|---|
| Không biết convention | Bổ sung vào AGENTS.md |
| Chạy lệnh nguy hiểm | Thêm blocking hook |
| Lạc hướng task dài | Tách planner / executor |
| Ship code lỗi | Nối typecheck back-pressure |
02
Guides ↔ Sensors · Computational ↔ Inferential
Con người (Steering Loop) liên tục cải thiện cả Guides lẫn Sensors theo thời gian
AGENTS.md, how-to skills, ref docs, Language Server (LSP), MCP tools.
| Tiêu chí | Computational | Inferential |
|---|---|---|
| Bản chất | Deterministic, chạy trên CPU | Suy luận ngữ nghĩa qua LLM / GPU |
| Ví dụ | Unit test, lint, type check, ArchUnit, dep-cruiser | AI code review, LLM-as-judge, semantic diff |
| Tốc độ & chi phí | ms → s, gần như miễn phí | s → phút, tốn token |
| Độ tin cậy | Cao, ổn định, lặp lại được | Xác suất, có thể sai |
| Phạm vi đo | Cú pháp, cấu trúc, coverage | Ý đồ, ngữ cảnh, ngữ nghĩa |
03
AGENTS.md · Tools & MCP · Sub-agents · Hooks & Lint
docs/ là System of Record HumanLayer · OpenAIAGENTS.md ← ~100 dòng, bản đồ
ARCHITECTURE.md ← sơ đồ domain + layer
docs/
├── design-docs/ ← quyết định thiết kế
│ ├── index.md
│ └── core-beliefs.md
├── exec-plans/ ← kế hoạch đang chạy
│ ├── active/
│ └── tech-debt-tracker.md
├── product-specs/ ← spec tính năng
├── references/ ← llms.txt thư viện
├── DESIGN.md
├── QUALITY_SCORE.md
└── SECURITY.md
Tool overload: mỗi MCP tool description chiếm context — agent vào "dumb zone" sớm hơn
npm install random-package — review trước khi cài.
Sub-agent = context firewall — noise của subtask không tích lũy vào parent session
Hook chạy tự động tại lifecycle event — tương tự git hook nhưng linh hoạt.
| Event | Hook |
|---|---|
| Sau mỗi edit file | Typecheck, lint, format |
| Trước commit | Test, coverage, dep-cruiser |
| Trước push / PR | Human approval required |
| Lệnh nguy hiểm | Block rm -rf, DROP TABLE |
# Hook chạy sau mỗi edit
biome format --write . 2>/dev/null
tsc --noEmit 2>&1 \
| grep -E "error" && exit 1 || exit 0
04
Maintainability · Architecture Fitness · Behaviour
Trục ngang: Guides ↔ Sensors · Trục dọc: 3 chiều kiểm soát
Mỗi domain: Types → Config → Repo → Providers → Service → Runtime → UI. Cross-cutting chỉ qua Providers
05
Context Rot · Compaction · Long-horizon execution
Compaction: sub-agent trả bản tóm tắt kèm source citation — parent context nhận thông tin đã chắt lọc
Mỗi gap hành vi của model → thiết kế component harness tương ứng
06
Keep Quality Left · Observability · Merge gate · Entropy · Templates
Feedforward → Tự sửa lần 1 → Human review → Integration → Post-integration pipeline
LogQL / PromQL / TraceQL. Teardown sau khi task xong.
App → Vector → stack quan sát → agent query & suy luận → fix → restart → lặp lại
Coding agent copy pattern đã có trong repo — kể cả pattern xấu. Theo thời gian → architectural drift.
Mỗi topology → 1 bộ guides + sensors sẵn có
07
Boring Tech · Co-evolution · Harness-as-a-Service
Bài toán: chạy 100 API call, tối đa 5 cái cùng lúc.
import pLimit from 'p-limit';
const limit = pLimit(5);
await Promise.all(
items.map(i => limit(() => callApi(i)))
);
async function mapWithConcurrency(
items, fn, limit) {
const running = new Set();
for (const item of items) {
const p = fn(item).then(
() => running.delete(p));
running.add(p);
if (running.size >= limit)
await Promise.race(running);
}
await Promise.all(running);
}
Promise — API không đổi bao giờ
Harness và model co-evolve: primitive trong harness hôm nay → capability của model ngày mai
Claude Code — harness production 7 layer (tham chiếu kiến trúc HaaS)
docs/ là System of Record — mọi tri thức encode thành markdown có phiên bản.