AgentHarness 课程
从 0 到 1 构建 nano Claude Code-like agent,每次只加一个机制
核心模式
所有 AI 编程 Agent 共享同一个循环:调用模型、执行工具、回传结果。生产级系统会在其上叠加策略、权限和生命周期层。
while True:
response = client.messages.create(messages=messages, tools=tools)
if response.stop_reason != "tool_use":
break
for tool_call in response.content:
result = execute_tool(tool_call.name, tool_call.input)
messages.append(result)消息增长
观察 Agent 循环执行时消息数组的增长
学习路径
12 个渐进式课程,从简单循环到隔离化自治执行
Agent 循环
The minimal agent kernel is a while loop + one tool
工具系统
The loop stays the same; new tools register into the dispatch map
任务规划
An agent without a plan drifts; list the steps first, then execute
子 Agent
Subagents use independent messages[], keeping the main conversation clean
技能系统
Inject knowledge via tool_result when needed, not upfront in the system prompt
上下文压缩
Context will fill up; three-layer compression strategy enables infinite sessions
任务系统
A file-based task graph with ordering, parallelism, and dependencies -- the coordination backbone for multi-agent work
后台任务
Run slow operations in the background; the agent keeps thinking ahead
Agent 团队
When one agent can't finish, delegate to persistent teammates via async mailboxes
团队协议
One request-response pattern drives all team negotiation
自主 Agent
Teammates scan the board and claim tasks themselves; no need for the lead to assign each one
Worktree 任务隔离
Each works in its own directory; tasks manage goals, worktrees manage directories, bound by ID
架构层次
五个正交关注点组合成完整的 Agent