Harness The Workbench Around the Model
让模型"长出手脚"的基础设施:工具、文件、沙箱、权限、循环——把只会聊天的模型,变成能真正干活的系统。 The infrastructure that gives the model hands: tools, files, sandbox, permissions, loops — turning a chat-only model into a system that actually works.
什么是 Harness What Is a Harness
Harness(工作台 / 智能体运行框架)是包裹在大模型外围的一层基础设施:它把工具调用、文件与沙箱访问、Shell 执行、上下文管理、权限审批、运行循环与评测组装在一起,让模型不再只是"文字进、文字出",而是可以读取你的文件、运行你的代码、搜索网络、反复试错。
A Harness is the infrastructure layer wrapped around an LLM. It wires up tool calling, file & sandbox access, shell execution, context management, permission approvals, the execution loop, and evaluation, so the model can read your files, run your code, search the web, and iterate — not just exchange text.
模型 = 大脑 Model = Brain
负责思考、理解、生成方案与文本。
Thinks, understands, produces plans and text.
Harness = 身体 + 工具箱 + 操作规程 Harness = Body + Toolkit + Operating Rules
负责动手:调工具、读写文件、跑命令,并确保一切在权限与安全边界内进行。
Acts: calls tools, reads/writes files, runs commands — while enforcing permissions and safety.
裸模型 vs 接上 Harness Bare Model vs. Harness-Equipped
| 能力维度 Dimension | 裸模型 Bare LLM | 模型 + Harness LLM + Harness |
|---|---|---|
| 对话 / 生成文本 Chat / generate | ✅ 唯一能力 only ability | ✅ |
| 读取本地文件 Read local files | ❌ | ✅(沙箱限定范围)(scoped by sandbox) |
| 执行代码 / Shell Run code / shell | ❌ | ✅ |
| 访问网络 / 搜索 Web / search | ❌ | ✅ |
| 会话持久化与记忆 Session & memory | ❌(无状态)stateless | ✅(会话、上下文管理)sessions, context mgmt |
| 反复试错、重跑 Iterate & retry | ❌ | ✅(执行循环)execution loop |
| 安全与权限控制 Safety & permissions | ❌ 无控制 no control | ✅(审批、资源限制、评测)approvals, limits, eval |
The model decides what to do; the harness decides whether, how, and how to verify it.
Harness 的组成 Anatomy of a Harness
工具调用 Tool Calling
模型输出结构化指令("调用 ×× 工具,参数为 …"),Harness 代为执行并把结果回填给模型,模型据此继续。
The model emits a structured call ("invoke tool X with args…"), the harness executes it and feeds results back so the model can continue.
沙箱与文件访问 Sandbox & Files
把模型的"手"限定在指定目录内(如工作区),防止它乱动系统文件;读写都有策略约束。
Scopes the model's hands to a workspace so it cannot touch system files; reads/writes follow a policy.
代码执行 Code Execution
让模型直接运行 Python 等命令,看到真实输出与报错,从而"试错—修正"地完成编程任务。
Lets the model run commands, see real output and errors, and fix them iteratively.
权限与审批 Permissions & Approval
危险或越权操作需征求你的同意;资源消耗可设上限——这是放心让 AI 干活的前提。
Sensitive actions require your consent; resource use can be capped — the precondition for trusting AI with real work.
上下文管理 Context Management
维护会话历史、压缩过期内容、注入必要的工具结果,让模型"记得住"长任务。
Maintains session history, compacts stale content, and injects tool results so long tasks stay coherent.
循环与评测 Loop & Evaluation
允许模型反复尝试、观察结果、调整方案;任务完成后按目标评测是否真的完成。
Allows repeated attempts, observation, and replanning; evaluates completion against the goal.
MCP:连接工具的"通用插座" MCP: A Universal Socket for Tools
Model Context Protocol(MCP)是 Anthropic 于 2024 年提出的开放标准:它把"模型 ↔ 工具"的对接方式统一起来——工具开发者按 MCP 写一次服务,任何支持 MCP 的 Harness/Agent 都能即插即用,就像 USB-C 一样。
Model Context Protocol (MCP), an open standard introduced by Anthropic in 2024, unifies how models connect to tools: build an MCP server once, and any MCP-compatible harness/agent can plug in — like USB-C for AI tools.
- 文件系统、数据库、浏览器、GitHub、科学计算环境……都能做成 MCP 工具 Filesystems, databases, browsers, GitHub, scientific computing — all can become MCP tools
- 越来越多的编程工具(Claude Code、Cursor 等)都支持 MCP More and more coding tools (Claude Code, Cursor, …) support MCP
- 对射电天文来说,将来可以把 CASA、数据归档查询等封装成 MCP 服务,让 Agent 直接调用 For radio astronomy, one could wrap CASA or archive queries as MCP services for agents to call directly
实例 Spotlight:DeepSeek Harness Case Study: DeepSeek Harness
你现在正在使用的这个网站,就是运行在一个真实 Harness——DeepSeek Harness(DSH)——之上的。看它如何对应上面每个组件:
This very site is powered by a real harness — DeepSeek Harness (DSH). See how it maps to each component above:
| 组件 Component | 在 DSH 中的体现 How DSH implements it |
|---|---|
| 工具调用 Tool calling | 内置 read / write / edit / glob / grep / pwsh(PowerShell 执行)等工具 Built-in tools: read, write, edit, glob, grep, pwsh (PowerShell), … |
| 沙箱与权限 Sandbox & permissions | 文件操作受工作区策略约束(如 workspace-write),越权操作触发审批 File ops are bound to workspace policy; out-of-scope ops trigger approval |
| 上下文管理 Context | 会话持久化、工具结果回填、长任务目标追踪(goal tools)Session persistence, result feedback, goal tracking for long tasks |
| 循环与评测 Loop & eval | 后台任务(background jobs)、完成度评测与阻塞上报 Background jobs, completion/blocker reporting |
| 多智能体编排 Orchestration | 可派生子代理(subagents)、工作流脚本(workflows)并行分派 Subagents and workflow scripts for parallel delegation |
| Web / 搜索 Web / search | 内置 web_search 工具检索最新资料 Built-in web_search for up-to-date info |