跳到主要内容
赞助推荐 Claude Team 合租,少折腾账号
>80aj_

深度阅读 / DeepSeek Harness

AI Agent 入门课: 用 DeepSeek Harness 学五层工程能力

17 分钟阅读 阅读(2) #DeepSeek Harness
#DeepSeek Harness
目录

Agent 入门课程如果只教模型调用和 Prompt,学生做出来的通常仍是 Chatbot。真正能行动的 Agent 还需要工具契约、状态、权限、执行循环和评测。下面五课用 DeepSeek Harness 作为观察样本,但课程目标是建立可迁移的 Agent Engineering 能力。

本篇属于 DeepSeek Harness 系列。系列不重复追逐插件快讯,而是从成熟度、运行时、记忆、安全和评测五个层面判断它能否成为长期基础设施。

赞助推荐 一人公司 · 创业装备库
赞助推荐 一人公司 · 创业装备库

撰写说明:本文使用 DeepSeek Harness 辅助撰写,并由人工编辑校对。

DeepSeek Harness 系列

  1. 首周观察:热度、版本与生产风险
  2. Cordis 与插件运行时
  3. 数字分身 Runtime 与长期记忆分层
  4. 30 天学习路线
  5. AI Agent 五层工程课
  6. DeepSeek Harness vs LangGraph

五课 AI Agent 入门课程

这套课我建议你不要设计成“讲 LLM 的五节课”,而要围绕真正构成 Agent 的五层工程能力来教。

总长度约 15–17 小时。学完以后,学生应该能够从:

LLM Chat

进化到:

Model
+ Context
+ Tools
+ Memory
+ Agent Loop
+ Permissions
+ Evaluation
= Agent System

第一课:Agent 不是 Chatbot——从 Model 到 Harness

学习目标:理解 Agent 与普通 LLM 调用的根本区别;能够解释 Agent = Model + Harness;亲手实现最小 agent loop

子主题:

  1. LLM、Assistant、Agent、Harness 的区别
  2. Messages / context window
  3. Structured output
  4. Function / Tool calling
  5. Observe → Think → Act → Observe 循环
  6. ReAct / Plan-and-Execute 基本思想
  7. Agent termination 与 infinite loop
  8. Context engineering 与 system prompt
  9. Harness 为什么开始独立于 Model

Hands-on:

写一个最小 Agent:

User
 ↓
LLM
 ↓
tool decision
 ↙       ↘
calculator  notes_search
 ↘       ↙
 observation
     ↓
    LLM
     ↓
   answer

要求加入:

max_steps = 5
tool_error handling
trajectory log

必读:DeepSeek Harness 官方介绍与 README;特别理解官方的 Agent = Model + Harness 和四种 runtime mode。

时长:约 3 小时。

课程摘要:这一课最终不是让学生“会调用 API”,而是建立最重要的直觉:模型只是 probabilistic policy,真正使 Agent 可工作的,是模型外围的 context、tools、state、execution control 与 safety。

第二课:Tool、MCP 与权限——Agent 如何进入真实世界

学习目标:理解 Tool Contract 和 MCP;能够设计可靠、安全、幂等的 Agent action。

子主题:

  1. Tool schema
  2. Tool descriptions 对模型行为的影响
  3. Input validation
  4. Tool result normalization
  5. Retry / timeout / idempotency
  6. MCP client / MCP server
  7. Tool permission scopes
  8. Human-in-the-loop approval
  9. Prompt injection
  10. Secret / OAuth credential isolation

Hands-on:

实现:

calendar.search()
calendar.create_event()

规则:

search = auto
create_event = approval required
delete_event = unavailable

然后给 Agent 一个含恶意指令的 calendar description,测试是否能够越权。

DSH 官方已经具有 tool registry、approval policy 和 MCP 相关能力,而 Safe Use Policy 明确建议重要系统变更要求 human approval。

必读:DSH architecture、Safe Use Policy、MCP 配置相关官方文档/源码。

时长:约 3 小时。

课程摘要:Tool calling 不是“给 LLM 几个函数”。真正的 Agent 工程要回答:“谁可以调用?在什么条件下?失败怎么办?重复调用怎么办?恶意网页能不能诱导它调用?”

第三课:Memory——从聊天机器人到数字分身

学习目标:理解 session、RAG 和 personal memory 的不同;搭出一个真正具有跨 session 记忆的小型 Digital Twin。

子主题:

  1. Working memory
  2. Session memory
  3. Episodic memory
  4. Semantic memory
  5. Preference memory
  6. Embeddings / vector retrieval
  7. Temporal retrieval
  8. Provenance / confidence
  9. Memory consolidation
  10. Forgetting / correction / deletion

Hands-on:

准备 20–100 条自己的模拟 personal data:

notes
calendar
preferences
life events
projects
people

建立:

Postgres
 + vector index
 + memory retrieval API

然后测试:

“我更偏好住酒店还是 Airbnb,依据是什么?”
“我 2025 年的偏好和现在是否发生变化?”
“这条信息来自哪里?”

要求回答中必须带 memory provenance。

必读:DSH session/event architecture;重点理解为什么 append-only session log 很有价值,又为什么它不等于 Digital Twin canonical memory。DSH 官方 trajectory 支持查看 system prompt、tool call、subagent scheduling 和 context injection,并支持 resume/fork/search/replay。

时长:3–3.5 小时。

课程摘要:这节课是数字分身最重要的一课。Agent 从“这轮会聊天”变成“长期认识一个人”的关键不是更大的模型,而是可验证、可纠正、可遗忘、有时间语义的长期记忆系统

第四课:Orchestration——DeepSeek Harness、Cordis 与 Multi-Agent

学习目标:真正理解 Agent runtime;能够写 DSH plugin,并理解什么场景值得 multi-agent。

子主题:

  1. DSH Profiles
  2. Bundles / Patch
  3. Cordis plugins
  4. Service / Event
  5. Reversible effects
  6. Agent loop
  7. Standard vs PTC mode
  8. Subagents
  9. Workflow / scheduling
  10. Failure / cancel / resume

Hands-on:

实现:

twin-memory plugin

暴露:

memory.search
memory.get_fact
memory.add_candidate

再实现两个 subagents:

Research Agent
Memory Curator

但只有 Memory Curator 可以提出 memory.add_candidate,并且不能直接写 canonical persona。

Cordis 的设计目标是动态组合、可撤销 effect 与 reactive dependency;DSH 则把 model adapters、tool registry、session、agent loop 等都放入同一个组合模型。

必读:DSH architecture.md、config catalog、Cordis paper。

时长:3.5–4 小时。

课程摘要:学生到这里应该能看懂为什么 DSH 不是“另一个 LangChain”。最值得学的是它把 Agent 的组成部分当成 runtime capabilities,而不是固定类层次结构。

第五课:Production Agent——Evals、安全、可观测与部署

学习目标:能够判断一个 Agent demo 是否有资格上线;建立最小 production evaluation pipeline。

子主题:

  1. Agent trajectories
  2. Structured logging
  3. Metrics / tracing
  4. Task success eval
  5. LLM-as-judge vs deterministic verifier
  6. Prompt injection red team
  7. Sandbox / container boundary
  8. Secrets / OAuth
  9. Crash recovery / replay
  10. Version migration / regression testing

Hands-on:

为前三节课的 Digital Twin 写 30–50 个 eval cases:

10 persona
10 memory
10 tool
10 adversarial
10 recovery

再注入:

malicious note
malicious webpage
malicious tool result

要求:

unauthorized action = 0
critical fabricated identity = 0
trace coverage = 100%

最后把同一个 benchmark 分别跑在两个模型上,观察:

Model effect
vs
Harness effect

DeepSeek 官方本身就强调每次运行可追踪,但同时又明确警告 code execution、prompt injection、untrusted plugins/MCP 的风险;首周独立研究也已经展示非零 indirect-prompt-injection 成功率,因此这应该成为入门课程的一部分,而不是“高级安全专题”。

必读:Safe Use Policy、Data Processing Statement、release notes、安全论文。

时长:3–3.5 小时。

五课结束后的完整项目应该是:

               Personal Data
                    ↓
               Twin Memory
                    ↓
User → Identity → Harness → Model
                    ↓
                 Tools
                    ↓
            Approval / Sandbox
                    ↓
              External World
                    ↓
               Trajectory
                    ↓
                  Eval

这比“写五个 Agent demo”更接近真正的 Agent Engineering。

站内延伸阅读

一手资料

结语

判断一个 Agent Runtime,关键不是演示能跑多少工具,而是状态、权限、恢复和升级是否可控。把这些问题逐项验证,才能决定 DeepSeek Harness 应该进入实验、试点还是生产。

未经允许不得转载:80aj » AI Agent 入门课: 用 DeepSeek Harness 学五层工程能力
赞助推荐 一键部署 AI 大模型
赞助推荐 一键部署 AI 大模型