AI Harness 101:让 AI 稳定工作的上下文与护栏
Page card
- Part:Part 1 / 基础扫盲
- 适用角色:开发、产品、设计、QA
- 使用场景:解释为什么 AI 不只是 prompt,而是一套可控工作环境
- 输出物:团队共用的
harness心智模型
Related jumps
Back to AI Workflow Sharing。相邻主题:Glossary - AI Workflow 术语表 · Evidence-first · Context building · Workflow design
Summary
核心心智模型:Prompt 是你说的话;harness 是让 AI 真正能可靠做事的工作台。
AI harness 指的是让 AI 能稳定完成任务的一整套环境:上下文、目标、工具、权限、约束、验证方式、记忆和输出格式。
为什么需要这个概念
如果只讨论 prompt,大家很容易把 AI 使用理解成“一次问答”。但真实工作里,我们更需要 AI 能持续参与一个 workflow:理解上下文、调用工具、执行任务、验证结果、沉淀经验。
这套让 AI 可执行、可观察、可验证的结构,就是 harness。
通俗理解
Prompt = 你对 AI 说什么
Harness = AI 在什么环境里工作、能用什么工具、受什么约束、怎么判断做对
Harness 包含什么
Context:AI 当前知道什么,例如文档、PR、日志、issue、设计稿、会议结论。Goal:这次任务要达成什么结果。Tools:AI 能使用什么工具,例如 GitHub、Notion、terminal、browser、test runner。Constraints:不能做什么,例如不能扩大 scope、不能泄露私人材料、不能跳过验证。Verification:怎么判断结果正确,例如测试、CI、review、人工确认。Memory / Docs:哪些经验会被沉淀,供下一次复用。Output format:结果应该以 findings、plan、summary、decision log 还是 PR comment 输出。
和 8 个方向的关系
- Evidence-first:给 harness 放真实证据。
- Context building:构建上下文 harness。
- Hypothesis loop:用验证循环约束 AI。
- Minimum viable change:用 scope 和 tests 控制执行。
- AI-assisted review:用 severity 和 evidence 约束 review。
- Agentic execution:给 AI 工具和闭环。
- Knowledge capture:把经验写回 harness。
- Workflow design:设计整个 harness。
开发侧例子
OpenSpec 可以理解成开发场景里的重要 harness(把规格作为交付契约):
Spec = source of truth
SuperPowers = execution discipline
AGENTS.md / CLAUDE.md = repo rules
Tests / PR checks = verification harness
Notion = discussion and draft space
Takeaway
我们不是只要更好的 prompt,而是要更好的 AI 工作环境。
References
- Harness Engineering: How to Build Reliable AI Agents by Engineering the System, Not the Model — 很适合作为
harness概念的外部支撑:强调可靠性问题往往不是 model 问题,而是 tools、memory、guardrails、verification、orchestration 的系统问题。 - What is an agent harness in the context of large-language models? — 对
agent harness做了通俗解释,适合给非开发听众建立“model 外围系统”的概念。 - Harnesses in AI: A Deep Dive — Tejas Kumar, IBM — 用 browser agent demo 解释 harness 如何通过 context、guardrails、verification 改善 agent 可靠性,适合做现场例子。
- Effective context engineering for AI agents — Anthropic 对 agent context state、tools、memory、context management 的工程化说明,可作为
harness和context engineering的连接材料。 - 【必看】Pi作者 - 我受够了所有 AI Agent,自己造了一个(Mario Zechner) — 中文讨论材料:用
pi的极简设计反问 skill、MCP、subagent 是否总是必要;适合说明 harness 可以很轻,但必须可控、可观察、可扩展。 - 【必看】PI架构深度解析|Agent循环、工具调用、TUI与更多 — 中文架构材料:围绕
Agent Loop、context 初始化、tool descriptions、skill descriptions、session tree 和 context compression 解释 agent harness 的组成。