Agent harness: model + harness = agent
model อ่านข้อความแล้วเขียนข้อความ ตัวมันเองเปิดไฟล์หรือรัน test ไม่ได้ agent ที่เราใช้คือ model ตัวนั้นใน harness: loop ที่ให้ tool กับมัน รันสิ่งที่มันขอตามกฎ และดูแล context ของมัน ดูมันแก้ bug เล็ก ๆ หนึ่งตัว แล้วลองเปลี่ยนกฎกับขนาด window ดูว่าอะไรเปลี่ยน
สิ่งที่จะได้
- อธิบายได้ว่า loop ที่ทำให้ model เป็น agent ทำงานยังไง: เรียก tool ใส่ผลกลับ แล้วถามใหม่
- ตั้ง allow, ask หรือ deny ให้แต่ละ tool ได้ และรู้ว่ากฎพวกนี้ไม่ใช่กำแพงกันภัย
- รู้ว่า compaction เก็บอะไรและทิ้งอะไร ตอน context window ใกล้เต็ม
- เห็นว่าทำไม model ตัวเดียวกันทำงานได้ดีในบาง harness มากกว่าอีกตัว
สรุป 1 นาที
กดข้อไหน ภาพข้างล่างจะเล่นขั้นนั้นให้ดู
คุณtest_add ไม่ผ่าน หาสาเหตุแล้วแก้ให้หน่อย
model ตัวเดิมทุกครั้ง เปลี่ยนแค่ harness: ดูว่ามันถามคุณกี่ครั้ง และไฟล์ของคุณเปลี่ยนไหม
agent ขอให้รัน test แล้วผลก็กลับมา ใครเป็นคนรัน test จริง ๆ
ในภาพ: อาคาร model อยู่ตรงกลาง harness คือถนนวงแหวนรอบมัน ทุกรอบ context ออกจากโกดังกระจกไปที่อาคาร model แล้ว model เขียนการเรียก tool (แผ่นบนหลังคา) harness อ่านมันตรงที่ทางออกมาบรรจบถนนวงแหวน แล้วด่านกฎติดไฟเขียว (allow) เหลือง (ask) หรือแดง (deny) ร้าน shell รัน test (ไฟสองดวงบนหลังคา) ร้าน files เก็บโปรเจกต์ของคุณ ผลวิ่งกลับเป็นแสงเข้าโกดัง ซึ่งแผ่นที่ซ้อนกันคือ context เส้นประคือสามในสี่ของ window และการสรุป context บีบแผ่นเก่าเป็นกล่องสรุปสีทองกล่องเดียว terminal ของคุณ (หรือแชตธรรมดาเมื่อไม่มี harness) อยู่ทางซ้าย (บนมือถืออยู่ใต้ภาพ) model เป็นตัวแทนที่เขียนเป็นกฎ ไม่ใช่ model จริง ส่วน tool รันจริงบนโปรเจกต์สองไฟล์ใน harness.py ด้านล่าง ตัวเลขนับเป็นคำแทน token เป็นตัวเลขไว้สอน model จริงนับเป็น token และมี window ใหญ่กว่านี้มาก
เทียบทุกแบบ: Agent harness
model ตัวเดียวกัน งานเดียวกัน (test_add ไม่ผ่าน แก้ให้หน่อย) ใน harness สี่แบบที่เจอบ่อย ดูว่าแต่ละแบบให้ tool อะไร ถามคุณกี่ครั้ง และงานไปจบที่ไหน
ใช้เมื่อ ถามคำถาม ขอคำอธิบาย ให้ช่วยดูโค้ดที่วางให้
ไม่ควรใช้เมื่อ งานที่ต้องเปิดไฟล์หรือรัน test: คุณกลายเป็น harness เอง คัดลอกไปมาทุกรอบ
model คือตัวแทนที่เขียนเป็นกฎ ไม่ใช่ model จริง ส่วน tool รันจริงกับโปรเจกต์ของเล่นใน harness.py สี่แบบนี้เป็นรูปแบบทั่วไป ไม่ใช่ผลิตภัณฑ์ใดผลิตภัณฑ์หนึ่ง รูปแบบกฎ allow / ask / deny และ sandbox มาจากเอกสารของ coding agent อย่าง Claude Code กับ Codex · กดช่องไหนก็ได้ ภาพใหญ่ด้านบนจะเปลี่ยนเป็นแบบนั้น พร้อมบอกว่าเหมาะกับงานแบบไหน
harness สี่แบบ model ตัวเดียว
| Harness | tool ที่ให้ | ถามคุณก่อน | ทำงานที่ไหน | จบด้วย |
|---|---|---|---|---|
| แชต ไม่มี tool | ไม่มี | ไม่ถาม | ไม่มีอะไรรัน | คำแนะนำ คุณแก้เอง |
| ผู้ช่วยใน editor ที่ถามก่อน | run_tests, read_file, edit_file | run_tests, edit_file | ในโฟลเดอร์ของคุณ | แก้แล้วในโฟลเดอร์ของคุณ |
| agent ใน terminal ที่ตั้งกฎไว้ | run_tests, read_file, edit_file | edit_file | ในโฟลเดอร์ของคุณ | แก้แล้วในโฟลเดอร์ของคุณ |
| agent เบื้องหลังใน sandbox | run_tests, read_file, edit_file, open_pr | ไม่ถาม | ในสำเนา (sandbox) | pull request ให้คุณตรวจ |
Loop ของ agent
เมื่อได้รายการ tool, model ตอบกลับเป็นคำขอเรียก tool หนึ่งตัวพร้อมค่าที่จะส่งได้ แล้วหยุด มันไม่ได้รันอะไรเอง ที่เหลือเป็นงานของ harness: ประกอบ context (system prompt, tool กับคำอธิบาย, งานของคุณ) ส่งไป รัน tool ที่ model ขอ ต่อคำขอกับผลเข้า context แล้วส่งใหม่ วนจนกว่า model จะตอบโดยไม่ขอ tool บทความ Building effective agents ของ Anthropic อธิบาย agent ว่าเป็น model ที่ใช้ tool ตามผลที่ได้จากสภาพแวดล้อมวนเป็น loop ส่วนเอกสาร tool use ของ Anthropic และ function calling ของ OpenAI ต่างให้โค้ดของคุณเป็นคนรัน tool บาง tool มากับ harness (อ่านไฟล์ รันคำสั่ง) บางตัวมาจากภายนอกผ่าน MCP มาตรฐานเปิดสำหรับต่อแอป AI เข้ากับระบบอื่น
Context กับ compaction
ทุกอย่างที่ model รู้เกี่ยวกับงานอยู่ใน context: system prompt, tool, งานของคุณ, ทุกการเรียกและทุกผล window มีขนาดตายตัว และบทความ Effective context engineering ของ Anthropic บอกว่ายิ่ง context ยาว model ยิ่งดึงข้อมูลในนั้นได้แม่นน้อยลง พอใกล้เต็ม harness จะทำ compaction: ให้ model สรุปงานที่ผ่านมา เก็บสิ่งที่ตัดสินใจไปแล้ว bug ที่ยังไม่แก้ และรายละเอียดที่ยังต้องใช้ แล้วเริ่ม context ใหม่จากสรุปนั้น ในภาพ harness สรุปเมื่อ context ถึงสามในสี่ของ window
กฎ: allow, ask, deny
ก่อนรันแต่ละคำขอ harness ดูกฎของ tool นั้น: allow รันเลย ask หยุดถามคุณ deny ไม่รันและบอก model เช่น Claude Code อ่านไฟล์ได้โดยไม่ถาม ถามก่อนรันคำสั่งและแก้ไฟล์ตามค่าเริ่มต้น และดูกฎ deny ก่อน แล้ว ask แล้ว allow ส่วน Codex มีโหมด read-only, workspace-write และ full access และปิด network เป็นค่าเริ่มต้นเมื่อเขียนใน workspace กฎจับข้อความของคำสั่ง จึงเป็นความสะดวกมากกว่ารั้ว เอกสารของ Claude Code บอกว่ากฎของคำสั่งไม่ใช่รั้วกันภัย ถ้าจะปล่อยให้ agent ทำเองทั้งหมด รั้วจริงคือ sandbox, container หรือ VM
model เดิม harness อื่น
เอา model ตัวเดียวใส่ใน harness สี่แบบข้างบน ได้ผลสี่แบบ: คำแนะนำที่คุณต้องลงมือเอง การแก้ที่คุณอนุมัติทีละขั้น การแก้ที่ถามครั้งเดียว และ pull request ที่ทำในสำเนา สิ่งที่เปลี่ยนคือ harness ให้อะไรกับ model ยอมให้อะไรรัน และเก็บอะไรไว้ใน context ตอน Anthropic ทำ agent สำหรับ SWE-bench ก็เจอแบบเดียวกัน พวกเขาใช้เวลาปรับ tool มากกว่าปรับ prompt และพอ tool ไฟล์บังคับให้ใช้ path เต็ม model ก็เลิกพลาดเรื่อง path ถ้า agent ทำงานได้ดีหรือแย่ ให้ดูทั้ง harness และ model
ในโค้ดจริง
# A toy agent harness. The "model" is a stand-in written as plain rules (no real model, no network, no key): it reads
# the context and either calls a tool or answers. Everything else is the harness: the loop, real tools on a project in
# a temporary folder, a permission rule per tool (allow / ask / deny), a context window counted in words, and
# compaction when the window is three quarters full. The same stand-in behaves differently in each setup below.
# Run: python3 harness.py
import difflib
import shutil
import sys
import tempfile
import traceback
import types
from pathlib import Path
SYSTEM = "You are a coding agent working in a project folder. Look before you change anything, run the tests after a change, keep answers short."
TOOLS = {
"run_tests": "run_tests(): run the project's tests and say which pass and which fail.",
"read_file": "read_file(path): return the text of one file in the project.",
"edit_file": "edit_file(path, old, new): replace the text old with new in one file.",
"open_pr": "open_pr(title): put the change on a new branch and open a pull request for review.",
}
TASK = "test_add fails. Find out why and fix it."
PROJECT = {
"calc.py": '"""Small helpers for the checkout page."""\n\n\ndef add(a, b):\n """Return the sum of a and b."""\n return a - b\n\n\ndef mul(a, b):\n """Return a times b."""\n return a * b\n',
"test_calc.py": "from calc import add, mul\n\n\ndef test_add():\n assert add(2, 3) == 5\n\n\ndef test_mul():\n assert mul(2, 3) == 6\n",
}
def words(text: str) -> int:
return len(text.split())
def size(context: list[str]) -> int:
return words("\n".join(context))
def run_tests(folder: Path) -> str:
calc = types.ModuleType("calc")
exec(compile((folder / "calc.py").read_text(), str(folder / "calc.py"), "exec"), calc.__dict__)
sys.modules["calc"] = calc # so the test file's "from calc import ..." finds this copy
tests: dict = {}
exec(compile((folder / "test_calc.py").read_text(), str(folder / "test_calc.py"), "exec"), tests)
del sys.modules["calc"]
failed = []
for name in ("test_add", "test_mul"):
try:
tests[name]()
except AssertionError as e:
failed.append(f"{name} FAILED ({traceback.extract_tb(e.__traceback__)[-1].line})")
return f"tests: {2 - len(failed)} passed" + "".join(f", {f}" for f in failed)
def stand_in_model(context: list[str], tools: list[str]) -> tuple[str, str]:
"""Rules in place of a model: ("call", tool + arguments) or ("answer", text)."""
seen = "\n".join(context).__contains__
if not tools:
return "answer", "I can't open your files or run the tests from here. Paste calc.py and the test output and I'll point at the bug."
refused = seen("denied: edit_file") or seen("you said no to edit_file")
if not seen("tests:"):
return "call", "run_tests()"
if not seen("read test_calc.py"):
return "call", 'read_file("test_calc.py")'
if not seen("read calc.py"):
return "call", 'read_file("calc.py")'
if not seen("edited calc.py") and not refused:
return "call", 'edit_file("calc.py", "return a - b", "return a + b")'
if seen("edited calc.py") and not seen("tests: 2 passed"):
return "call", "run_tests()"
if "open_pr" in tools and not seen("pull request #"):
return "call", 'open_pr("Fix add(): it subtracted")'
if seen("pull request #"):
return "answer", "Opened pull request #1: add() subtracted, it now adds. Both tests pass."
if seen("edited calc.py"):
return "answer", "Fixed: add() returned a - b, it now returns a + b. Both tests pass."
return "answer", "I didn't change anything. The bug: in calc.py, add() returns a - b; it should return a + b."
def summarise(context: list[str]) -> str:
"""Compaction: a real harness asks the model for this summary; the stand-in keeps each result's first line and the bug it found."""
keep = [m.split("\n", 1)[0] for m in context[3:] if not m.startswith("calls ")]
if any("return a - b" in m and m.startswith("read calc.py") for m in context):
keep.append("calc.py line 6: return a - b (should be a + b)")
return "Summary of earlier work: " + "; ".join(keep)
def harness(rules: dict, window: int, say: str = "yes", sandbox: bool = False) -> list[str]:
with tempfile.TemporaryDirectory() as tmp:
home = Path(tmp) / "project" # your folder
home.mkdir()
for name, text in PROJECT.items():
(home / name).write_text(text)
work = Path(shutil.copytree(home, Path(tmp) / "sandbox")) if sandbox else home
log = loop(rules, window, say, work)
fixed = "return a + b" in (home / "calc.py").read_text()
return log + [f"your folder: add() {'returns a + b' if fixed else 'still returns a - b'}"]
def loop(rules: dict, window: int, say: str, work: Path) -> list[str]:
"""The harness itself: context in, the model's reply out, the tool run (or not), its result back in, again."""
tools = list(rules)
context = [SYSTEM, "\n".join(TOOLS[t] for t in tools), TASK]
log, turn = [], 0
while True:
if size(context) > window * 3 // 4:
before = size(context)
context = context[:3] + [summarise(context)]
log.append(f"compacted: {before} -> {size(context)} words")
turn += 1
kind, text = stand_in_model(context, tools)
if kind == "answer":
context.append(text)
log.append(f"turn {turn}: answer: {text} | context {size(context)}/{window}")
break
name = text.split("(")[0]
rule = rules[name]
if rule == "ask":
rule = say if name == "edit_file" else "yes"
decision = f"asked you: {rule}"
else:
decision = "allowed" if rule == "allow" else "denied"
if rule in ("allow", "yes"):
if name == "run_tests":
result = run_tests(work)
elif name == "read_file":
path = text.split('"')[1]
body = (work / path).read_text()
result = f"read {path} ({len(body.splitlines())} lines):\n{body}"
elif name == "edit_file":
body = (work / "calc.py").read_text()
assert body.count("return a - b") == 1
(work / "calc.py").write_text(body.replace("return a - b", "return a + b"))
result = "edited calc.py: line 6 is now return a + b"
else:
diff = difflib.unified_diff(PROJECT["calc.py"].splitlines(), (work / "calc.py").read_text().splitlines(), lineterm="", n=0)
changed = [d for d in diff if d[:1] in "+-" and d[:3] not in ("+++", "---")]
result = f"pull request #1 opened: {' | '.join(changed)}"
elif rule == "no":
result = f"you said no to {name}"
else:
result = f"denied: {name} is not allowed here"
context += [f"calls {text}", result]
first_line = result.splitlines()[0]
log.append(f"turn {turn}: {text} -> {decision} -> {first_line} | context {size(context)}/{window}")
return log
SETUPS = {
"allow everything, window 1000": dict(rules={"run_tests": "allow", "read_file": "allow", "edit_file": "allow"}, window=1000),
"ask before edits": dict(rules={"run_tests": "allow", "read_file": "allow", "edit_file": "ask"}, window=1000),
"ask before edits, you say no": dict(rules={"run_tests": "allow", "read_file": "allow", "edit_file": "ask"}, window=1000, say="no"),
"ask before every tool": dict(rules={"run_tests": "ask", "read_file": "ask", "edit_file": "ask"}, window=1000),
"read-only": dict(rules={"run_tests": "allow", "read_file": "allow", "edit_file": "deny"}, window=1000),
"allow everything, window 180": dict(rules={"run_tests": "allow", "read_file": "allow", "edit_file": "allow"}, window=180),
"chat, no tools": dict(rules={}, window=1000),
"editor that asks": dict(rules={"run_tests": "ask", "read_file": "allow", "edit_file": "ask"}, window=1000),
"background, in a sandbox": dict(rules={"run_tests": "allow", "read_file": "allow", "edit_file": "allow", "open_pr": "allow"}, window=1000, sandbox=True),
}
for title, setup in SETUPS.items():
log = harness(**setup)
print(f"== {title}")
print("\n".join(log))
assert harness(**SETUPS["read-only"])[-1] == "your folder: add() still returns a - b"
assert harness(**SETUPS["background, in a sandbox"])[-1] == "your folder: add() still returns a - b"
assert sum(line.startswith("compacted") for line in harness(**SETUPS["allow everything, window 180"])) == 1
python3 harness.pyผลที่พิมพ์ออกมา:== allow everything, window 1000
turn 1: run_tests() -> allowed -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 78/1000
turn 2: read_file("test_calc.py") -> allowed -> read test_calc.py (9 lines): | context 103/1000
turn 3: read_file("calc.py") -> allowed -> read calc.py (11 lines): | context 140/1000
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> allowed -> edited calc.py: line 6 is now return a + b | context 160/1000
turn 5: run_tests() -> allowed -> tests: 2 passed | context 165/1000
turn 6: answer: Fixed: add() returned a - b, it now returns a + b. Both tests pass. | context 180/1000
your folder: add() returns a + b
== ask before edits
turn 1: run_tests() -> allowed -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 78/1000
turn 2: read_file("test_calc.py") -> allowed -> read test_calc.py (9 lines): | context 103/1000
turn 3: read_file("calc.py") -> allowed -> read calc.py (11 lines): | context 140/1000
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> asked you: yes -> edited calc.py: line 6 is now return a + b | context 160/1000
turn 5: run_tests() -> allowed -> tests: 2 passed | context 165/1000
turn 6: answer: Fixed: add() returned a - b, it now returns a + b. Both tests pass. | context 180/1000
your folder: add() returns a + b
== ask before edits, you say no
turn 1: run_tests() -> allowed -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 78/1000
turn 2: read_file("test_calc.py") -> allowed -> read test_calc.py (9 lines): | context 103/1000
turn 3: read_file("calc.py") -> allowed -> read calc.py (11 lines): | context 140/1000
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> asked you: no -> you said no to edit_file | context 155/1000
turn 5: answer: I didn't change anything. The bug: in calc.py, add() returns a - b; it should return a + b. | context 174/1000
your folder: add() still returns a - b
== ask before every tool
turn 1: run_tests() -> asked you: yes -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 78/1000
turn 2: read_file("test_calc.py") -> asked you: yes -> read test_calc.py (9 lines): | context 103/1000
turn 3: read_file("calc.py") -> asked you: yes -> read calc.py (11 lines): | context 140/1000
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> asked you: yes -> edited calc.py: line 6 is now return a + b | context 160/1000
turn 5: run_tests() -> asked you: yes -> tests: 2 passed | context 165/1000
turn 6: answer: Fixed: add() returned a - b, it now returns a + b. Both tests pass. | context 180/1000
your folder: add() returns a + b
== read-only
turn 1: run_tests() -> allowed -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 78/1000
turn 2: read_file("test_calc.py") -> allowed -> read test_calc.py (9 lines): | context 103/1000
turn 3: read_file("calc.py") -> allowed -> read calc.py (11 lines): | context 140/1000
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> denied -> denied: edit_file is not allowed here | context 156/1000
turn 5: answer: I didn't change anything. The bug: in calc.py, add() returns a - b; it should return a + b. | context 175/1000
your folder: add() still returns a - b
== allow everything, window 180
turn 1: run_tests() -> allowed -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 78/180
turn 2: read_file("test_calc.py") -> allowed -> read test_calc.py (9 lines): | context 103/180
turn 3: read_file("calc.py") -> allowed -> read calc.py (11 lines): | context 140/180
compacted: 140 -> 100 words
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> allowed -> edited calc.py: line 6 is now return a + b | context 120/180
turn 5: run_tests() -> allowed -> tests: 2 passed | context 125/180
turn 6: answer: Fixed: add() returned a - b, it now returns a + b. Both tests pass. | context 140/180
your folder: add() returns a + b
== chat, no tools
turn 1: answer: I can't open your files or run the tests from here. Paste calc.py and the test output and I'll point at the bug. | context 55/1000
your folder: add() still returns a - b
== editor that asks
turn 1: run_tests() -> asked you: yes -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 78/1000
turn 2: read_file("test_calc.py") -> allowed -> read test_calc.py (9 lines): | context 103/1000
turn 3: read_file("calc.py") -> allowed -> read calc.py (11 lines): | context 140/1000
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> asked you: yes -> edited calc.py: line 6 is now return a + b | context 160/1000
turn 5: run_tests() -> asked you: yes -> tests: 2 passed | context 165/1000
turn 6: answer: Fixed: add() returned a - b, it now returns a + b. Both tests pass. | context 180/1000
your folder: add() returns a + b
== background, in a sandbox
turn 1: run_tests() -> allowed -> tests: 1 passed, test_add FAILED (assert add(2, 3) == 5) | context 93/1000
turn 2: read_file("test_calc.py") -> allowed -> read test_calc.py (9 lines): | context 118/1000
turn 3: read_file("calc.py") -> allowed -> read calc.py (11 lines): | context 155/1000
turn 4: edit_file("calc.py", "return a - b", "return a + b") -> allowed -> edited calc.py: line 6 is now return a + b | context 175/1000
turn 5: run_tests() -> allowed -> tests: 2 passed | context 180/1000
turn 6: open_pr("Fix add(): it subtracted") -> allowed -> pull request #1 opened: - return a - b | + return a + b | context 200/1000
turn 7: answer: Opened pull request #1: add() subtracted, it now adds. Both tests pass. | context 212/1000
your folder: add() still returns a - bloop รอบ model ตัวแทนที่เขียนเป็นกฎธรรมดา (ไม่มี model จริง ไม่มี key ไม่ต่อ network): tool จริงบนโปรเจกต์สองไฟล์ในโฟลเดอร์ชั่วคราว กฎหนึ่งข้อต่อ tool context window ที่นับเป็นคำ และ compaction ที่สามในสี่ เก้าแบบ ใช้ตัวแทนตัวเดียวกันทุกแบบ รันจริง
คำถามที่เจอบ่อย
agent harness คืออะไร
โปรแกรมที่ห่อ model ไว้ให้ทำงานเป็น agent ได้: ประกอบ context (system prompt รายการ tool งาน ผลที่ได้มา) ส่งให้ model รัน tool ที่ model ขอตามกฎ แล้ววนต่อ model เขียนได้แค่ข้อความ ส่วนที่ลงมือคือ harness
model รัน tool เองหรือเปล่า
ไม่ model ตอบกลับมาเป็นคำขอเรียก tool พร้อมค่าที่จะส่ง แล้วหยุด โค้ดของคุณหรือ harness เป็นคนรันจริงแล้วส่งผลกลับไป ทั้งเอกสาร tool use ของ Anthropic และ function calling ของ OpenAI อธิบายไว้แบบนี้
context เต็มแล้วเกิดอะไรขึ้น
context window มีขนาดจำกัด และ model ใช้ context ยาว ๆ ได้แย่ลงเมื่อมันยาวขึ้น harness จึงทำ compaction: ให้ model สรุปงานที่ผ่านมา เก็บเรื่องสำคัญอย่าง bug ที่ยังไม่แก้ ทิ้งผลดิบของ tool แล้วเริ่ม context ใหม่จากสรุปนั้น
ตั้งให้ agent ทำได้ทุกอย่างปลอดภัยไหม
ในเครื่องที่มีงานจริงไม่ควร กฎ allow หรือ deny จับข้อความของคำสั่ง โปรแกรมเดียวกันที่เรียกอีกแบบอาจหลุด เอกสารของ Claude Code บอกว่ากฎแบบนี้ไม่ใช่รั้วกันภัย ถ้าจะปล่อยให้ทำเองทั้งหมดให้ทำใน sandbox container หรือ VM
ทำไม model ตัวเดียวกันใช้ในเครื่องมือคนละตัวแล้วเก่งไม่เท่ากัน
เพราะ harness ต่างกัน: tool ที่ให้และคำอธิบายของมัน กฎ และสิ่งที่ใส่ใน context ตอน Anthropic ทำ agent สำหรับ SWE-bench พวกเขาใช้เวลาปรับ tool มากกว่าปรับ prompt เช่นบังคับให้ใช้ path เต็มแทน path สัมพัทธ์ จนความผิดพลาดแบบนั้นหายไป
tool ของ agent มาจากไหน
บางตัวมากับ harness อย่างอ่านไฟล์ แก้ไฟล์ รันคำสั่ง บางตัวมาจากภายนอกผ่าน MCP (Model Context Protocol) มาตรฐานเปิดที่ให้แอป AI ต่อกับระบบอื่นได้ ทุกตัวไปถึง model เป็นชื่อกับคำอธิบายใน context และต้องผ่านกฎของ harness เหมือนกัน
โหมดอ่านอย่างเดียวมีไว้ทำอะไร
ให้ agent สำรวจและวางแผนโดยไม่แตะไฟล์: มันอ่าน รัน test หาสาเหตุ แล้วเสนอวิธีแก้ คุณอ่านแล้วค่อยตัดสินใจ ในหน้านี้มันหา bug เจอเหมือนเดิมแต่โฟลเดอร์ของคุณไม่เปลี่ยน Claude Code มี plan mode และ Codex มี read-only แบบนี้
agent ต่างจาก workflow ยังไง
workflow เดินตามทางที่โค้ดเขียนไว้ล่วงหน้า เช่นเรียก model สามครั้งตามลำดับ agent ให้ model เลือกเองว่าจะเรียก tool ไหนต่อและจะหยุดเมื่อไหร่ ใน loop ของ harness Anthropic แนะนำให้ใช้ทางที่ง่ายที่สุดที่ใช้ได้ก่อน
บทต่อไป
การโจมตี AIระดับ: กลาง
tool ที่ harness ให้ กับกฎ allow, ask, deny คือจุดที่การโจมตี AI ถูกกันไว้หรือหลุดผ่าน บทต่อไปดูการโจมตีพวกนั้นเอง