本目录主体以 Anthropic Engineering Blog 官方技术博文为据;本页汇总可一起学习的非官方博文与资源的 Agent/LLM 工程与评测文章,便于拓展视野与对照实践。
使用说明
- 官方优先:各分片博文结论以 Anthropic 原文为准;本页为补充,不替代官方博文。
- 官方 GitHub 与源码:Anthropic 官方仓库(anthropic-sdk-python、claude-agent-sdk-python、claude-quickstarts 等)及与本系列的对应关系见 index.md 的「GitHub 与官方源码」小节;本页下表以非官方博文与资源为主。
- 真实引用:下表均给出标题与可访问链接;若链接失效可搜索标题或作者。
- 与分片对应:文末有「本目录模块 ↔ 延伸阅读」对照表,便于按主题深挖。
本页总流程图:延伸阅读使用顺序
可运行代码示例:按分片筛选延伸阅读条目
以下脚本从「与本目录分片对应」的映射中,按分片编号输出建议的延伸阅读标题,便于在本地或脚本中快速查表。不依赖网络,可直接运行。
# 按分片查延伸阅读建议(与 further-reading 表格一致)
# 运行:python further_reading_lookup.py [01-06]
EXTENSION_MAP = {
"01": ["53AI 设计范式", "阿里云企业级落地", "火山引擎 Anthropic 指南", "12-Factor Agents", "OpenAI 构建智能体"],
"02": ["阿里云工具基类与结构化输出", "OpenAI 工具类型与指令"],
"03": ["李乾坤博客 RAG/工作流相关", "Contextual Retrieval 与 RAG 进阶"],
"04": ["李乾坤 Multi-Agent", "阿里云状态与日志", "多 Agent 编排实践"],
"05": ["ICLR Agent Evaluation", "HAL", "Maxim 框架对比", "Efficient Coder 指南", "Tessl 8 benchmarks"],
"06": ["阿里云异常兜底与 Debug", "12-Factor 运维与配置"],
}
def main():
import sys
key = (sys.argv[1] or "01").strip()
if key not in EXTENSION_MAP:
print("Usage: further_reading_lookup.py [01|02|03|04|05|06]")
return
print(f"分片 {key} 建议对照延伸阅读:")
for i, title in enumerate(EXTENSION_MAP[key], 1):
print(f" {i}. {title}")
if __name__ == "__main__":
main()
示例:按分类列出延伸阅读标题与链接
若需要按「中文企业级 / 中文规范 / 英文厂商 / 英文评测」分类浏览,可用下面结构配合本页表格生成链接列表(链接需从正文表格复制):
# 按分类输出延伸阅读(标题 + 占位 URL)
SECTIONS = {
"一、中文企业级": ["53AI 设计范式", "阿里云企业级落地", "火山引擎 Anthropic 指南", "李乾坤 LLM Agent 实践", "小七洞 OpenAI 智能体指南"],
"二、中文规范": ["12-Factor Agents 中文"],
"三、英文厂商": ["OpenAI Building agents"],
"四、英文评测": ["ICLR Agent Evaluation", "HAL", "Maxim 框架对比", "Efficient Coder 指南", "Tessl 8 benchmarks"],
}
for section, titles in SECTIONS.items():
print(f"\n{section}")
for t in titles:
print(f" - {t}")
一、中文:企业级落地与设计范式
| 来源 | 标题 | 链接 | 要点 |
|---|---|---|---|
| 53AI | 别再只会用 LLM 了!2025 年最强 Agent 设计范式全解析 | 文章 | 2025 Agent 设计范式、简化优于复杂、工作流 vs Agent、企业级实践 |
| 阿里云开发者社区 | 从 0 到 1:企业级 LLM Agent 的工程化落地实践 | 文章 | 多工具协同、高并发状态、异常兜底、Debug;ReAct、工具基类、结构化输出、步数限制与日志 |
| 火山引擎 | 构建高效 AI Agent:Anthropic 架构设计与实践完全指南 | 文章 | Anthropic 架构与 Building Blocks 的中文解读与落地 |
| 李乾坤的博客 | LLM Agent 实践(2024) | 文章 | LangGraph 工作流、Function Calling、Multi-Agent 等实践汇总 |
| 小七洞 | OpenAI 构建智能体指南(中文) | 文章 | OpenAI 构建 Agent 的实践指南中文整理;工具类型(数据/操作/编排)、指令与任务分解 |
二、中文:设计原则与工程规范
| 来源 | 标题 | 链接 | 要点 |
|---|---|---|---|
| GitHub: 12-Factor Agents | 12-Factor Agents(中文) | 仓库 | 将 12-Factor App 思想应用到 Agent:可扩展、可运维的工程原则 |
三、英文:厂商与平台指南
| 来源 | 标题 | 链接 | 要点 |
|---|---|---|---|
| OpenAI | Building agents(官方) | 文档 | 工具类型、指令设计、任务分解(OpenAI 生态) |
四、英文:Agent 评测与 Benchmark(全网最新)
| 来源 | 标题 | 链接 | 要点 |
|---|---|---|---|
| ICLR Blogposts 2026 | A Hitchhiker’s Guide to Agent Evaluation | 文章 | Agent 评测与单轮 LLM 的三大差异:多步 vs 单步、outcome vs output、交互 vs 被动 |
| arXiv (2025) | Holistic Agent Leaderboard: The Missing Infrastructure for AI Agent Evaluation | 论文 | HAL:标准化评测 harness、多 VM 并行、多模型多 benchmark(coding、web、science、客服等) |
| Maxim | A Survey of Agent Evaluation Frameworks: Benchmarking the Benchmarks | 文章 | Agent 评测框架对比与 Benchmark 梳理 |
| Efficient Coder | AI Agent Evaluations: The Complete 2025-2026 Guide to Bulletproof Testing | 文章 | 评测实践、任务与 trial、grader、harness 等完整指南 |
| Tessl | 8 benchmarks shaping the next generation of AI agents | 文章 | SWE-bench、τ-Bench、WebArena、Terminal-Bench、SWT-Bench 等 8 大 benchmark 介绍 |
五、LangGraph 1.0 对照代码(与 01~06 正文片段等价)
以下为与正文 01~06 中可运行示例等价的 LangGraph 1.0 写法,便于在 LangGraph 栈下复现同一逻辑。环境:pip install langgraph langchain-anthropic,并设置 ANTHROPIC_API_KEY。模型 ID 与正文一致(如 claude-sonnet-4-20250514),当前型号见 Anthropic Models。
5.1 对应 01:单轮、链式、路由、Agent 循环
单轮调用(对应 01 §1.3)
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage
model = ChatAnthropic(model="claude-sonnet-4-20250514", max_tokens=512)
msg = model.invoke([HumanMessage(content="用一句话说明何时不必上 Agent。")])
print(msg.content)
Prompt chaining(对应 01 §3.8 示例 1)
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage, AIMessage
model = ChatAnthropic(model="claude-sonnet-4-20250514", max_tokens=2048)
step1 = model.invoke([HumanMessage(content="请为《如何做 Agent 选型》写一个 3 个小节的提纲。")])
outline = step1.content
step2 = model.invoke([
HumanMessage(content=f"根据以下提纲写正文:\n\n{outline}"),
])
print(step2.content[:500])
Routing(对应 01 §3.8 示例 2)
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage
model = ChatAnthropic(model="claude-sonnet-4-20250514", max_tokens=1024)
def route_and_respond(user_input: str) -> str:
route_msg = model.invoke([HumanMessage(
content=f"仅用一词回答:以下问题属于哪类?technical / billing / other\n\n{user_input}"
)])
kind = (route_msg.content or "").strip().lower()
if "technical" in kind:
prompt = f"【技术支援】请专业、简洁地回答:{user_input}"
elif "billing" in kind:
prompt = f"【账单与付费】请礼貌、清晰地回答:{user_input}"
else:
prompt = f"【一般咨询】请友好地回答:{user_input}"
resp = model.invoke([HumanMessage(content=prompt)])
return resp.content or ""
最小 Agent 循环(带工具,对应 01 §3.8 示例 3)
from typing import Annotated
from typing_extensions import TypedDict
from langchain_anthropic import ChatAnthropic
from langchain_core.tools import tool
from langchain_core.messages import HumanMessage, BaseMessage
from langgraph.graph import StateGraph, END
from langgraph.graph.message import add_messages
from langgraph.prebuilt import ToolNode
class State(TypedDict):
messages: Annotated[list[BaseMessage], add_messages]
@tool
def get_time() -> str:
"""返回当前 UTC 时间,用于需要时间的对话。"""
from datetime import datetime, timezone
return datetime.now(timezone.utc).isoformat()
tools = [get_time]
model = ChatAnthropic(model="claude-sonnet-4-20250514", max_tokens=1024).bind_tools(tools)
tool_node = ToolNode(tools)
def call_model(state: State) -> dict:
resp = model.invoke(state["messages"])
return {"messages": [resp]}
def should_continue(state: State) -> str:
last = state["messages"][-1]
if hasattr(last, "tool_calls") and last.tool_calls:
return "tools"
return "end"
graph_builder = StateGraph(State)
graph_builder.add_node("agent", call_model)
graph_builder.add_node("tools", tool_node)
graph_builder.set_entry_point("agent")
graph_builder.add_conditional_edges("agent", should_continue, {"tools": "tools", "end": END})
graph_builder.add_edge("tools", "agent")
graph = graph_builder.compile()
result = graph.invoke({"messages": [HumanMessage(content="现在几点了?请用工具确认后告诉我。")]})
print(result["messages"][-1].content)
5.2 对应 02:工具定义与调用、search_logs、eval、ResponseFormat
工具定义 + 单轮调用(对应 02 §3.2)
from langchain_anthropic import ChatAnthropic
from langchain_core.tools import tool
from langchain_core.messages import HumanMessage
from datetime import datetime, timezone
@tool
def get_utc_time() -> str:
"""返回当前 UTC 时间(ISO 8601)。用于用户问「几点了」等需要当前时间的场景。"""
return datetime.now(timezone.utc).isoformat()
@tool
def square_number(x: float) -> str:
"""计算一个数的平方。参数 x 必须为数字(int 或 float),否则返回错误说明。"""
try:
return str(float(x) ** 2)
except (TypeError, ValueError):
return "错误:x 必须是数字。请使用例如 {\"x\": 5} 或 {\"x\": 3.14}。"
tools = [get_utc_time, square_number]
model = ChatAnthropic(model="claude-sonnet-4-20250514", max_tokens=256).bind_tools(tools)
msg = model.invoke([HumanMessage(content="请用工具计算 7 的平方,并告诉我现在 UTC 时间。")])
# 若含 tool_calls,在图中用 ToolNode 执行后继续(见 5.1 Agent 循环)
print(msg.content)
search_logs 占位(对应 02 §5)
# db 为占位,实际需实现或接入真实数据源
def search_logs(query: str, limit: int = 50, offset: int = 0) -> str:
"""返回匹配的日志行;单次最多 limit 条,用 offset 分页。建议多次小范围查。"""
rows = [] # db.query_logs(query, limit=limit, offset=offset)
if len(rows) >= limit:
return "\n".join(rows) + f"\n[已截断,共 {limit} 条;可加大 offset 继续]"
return "\n".join(rows)
run_eval_n_trials(对应 02 §5)
def run_eval_n_trials(tasks: list[tuple[str, str]], n_trials: int = 3,
agent_harness=None, grader=None) -> list[dict]:
"""对每个 task 跑 n_trials 次,记录每次 passed 与 outcome。"""
agent_harness = agent_harness or (lambda x: ("", {}))
grader = grader or (lambda o: False)
results = []
for task_id, task_input in tasks:
trials = []
for _ in range(n_trials):
reply, outcome = agent_harness(task_input)
passed = grader(outcome)
trials.append({"passed": passed, "outcome": outcome})
results.append({"task_id": task_id, "trials": trials})
return results
ResponseFormat 枚举(对应 02 §3)
from enum import Enum
class ResponseFormat(Enum):
DETAILED = "detailed"
CONCISE = "concise"
5.3 对应 03:按需加载、笔记、Compaction
load_on_demand(对应 03 §2)
def load_on_demand(path: str) -> str:
"""按 path 返回内容;在 agent 循环中,仅当模型请求该 path 时再调用。"""
with open(path, "r", encoding="utf-8") as f:
return f.read()
append_note / read_notes(对应 03 §3.2)
NOTES_FILE = "NOTES.md"
def append_note(section: str, content: str) -> None:
with open(NOTES_FILE, "a", encoding="utf-8") as f:
f.write(f"\n## {section}\n{content}\n")
def read_notes() -> str:
try:
with open(NOTES_FILE, "r", encoding="utf-8") as f:
return f.read()
except FileNotFoundError:
return ""
轻量 Compaction(对应 03 §4.1)
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage
model = ChatAnthropic(model="claude-sonnet-4-20250514", max_tokens=512)
recent_conversation = """
[User] 请实现登录 API,要校验邮箱格式。
[Assistant] 已添加 validate_email 和 /login 路由;当前只支持密码登录。
[User] 再加一个「忘记密码」流程,发重置链接到邮箱。
"""
compaction_prompt = f"""请将以下开发对话压缩为一段简短摘要,用于在新对话中「接上进度」。
要求:保留架构/接口决策、未完成项、关键实现要点;去掉冗余细节与重复说明。
输出仅一段摘要,不要列表。
对话:
{recent_conversation}
"""
resp = model.invoke([HumanMessage(content=compaction_prompt)])
summary = resp.content or ""
# 新 context = 摘要 + 后续新消息
print("Compaction 摘要:", summary[:400])
5.4 对应 04:feature_list、next_unfinished
feature_list.json 与 next_unfinished(对应 04 §3.5)
import json
def next_unfinished(feature_list_path: str = "feature_list.json") -> dict | None:
with open(feature_list_path, "r", encoding="utf-8") as f:
items = json.load(f)
for i, item in enumerate(items):
if not item.get("passes", False):
return {"index": i, "description": item["description"], "steps": item.get("steps", [])}
return None
# 使用
if n := next_unfinished():
print(f"下一项: [{n['index']}] {n['description']}")
else:
print("全部完成")
5.5 对应 05:pass@k、pass^k、单次 Trial
pass_at_k / pass_all_k(对应 05 §3)
def pass_at_k(trial_results: list[bool]) -> bool:
return any(trial_results)
def pass_all_k(trial_results: list[bool]) -> bool:
return len(trial_results) > 0 and all(trial_results)
agent_harness、grader、run_one_trial(对应 05 §4.2)
def agent_harness(task_input: str) -> tuple[str, dict]:
"""模拟 Agent 一次 trial:返回 (final_reply, outcome)。"""
reply = "The quick brown fox jumps over the lazy dog."
outcome = {"reply_contains_fox": "fox" in reply.lower(), "length_ok": len(reply) > 10}
return reply, outcome
def grader(outcome: dict) -> bool:
return outcome.get("reply_contains_fox", False) and outcome.get("length_ok", False)
def run_one_trial(task_id: str, task_input: str) -> bool:
reply, outcome = agent_harness(task_input)
passed = grader(outcome)
print(f"Task {task_id} => passed={passed}, outcome={outcome}")
return passed
5.6 对应 06:执行环境自检、路径白名单
check_exec_env(对应 06 §2.1)
import os
import sys
def in_docker() -> bool:
try:
with open("/proc/1/cgroup", "r") as f:
return "docker" in f.read() or "containerd" in f.read()
except FileNotFoundError:
return False
def in_sandbox_root(allowed_root: str) -> bool:
cwd = os.path.realpath(os.getcwd())
return cwd == os.path.realpath(allowed_root) or cwd.startswith(os.path.realpath(allowed_root) + os.sep)
def check_exec_env(allowed_root: str = "/workspace") -> dict:
return {
"cwd": os.getcwd(),
"in_docker": in_docker(),
"in_allowed_root": in_sandbox_root(allowed_root),
}
resolve_in_allowed_root(对应 06 §2.1)
import os
def resolve_in_allowed_root(path: str, allowed_roots: list[str]) -> str | None:
"""将 path 解析为绝对路径;仅当位于某 allowed_root 下时返回,否则返回 None。"""
abs_path = os.path.realpath(os.path.abspath(path))
for root in allowed_roots:
abs_root = os.path.realpath(root)
if abs_path == abs_root or abs_path.startswith(abs_root + os.sep):
return abs_path
return None
六、与本目录分片博文的对应关系
| 本目录分片 | 建议对照延伸阅读 |
|---|---|
| 01 架构与选型 | 53AI 设计范式、阿里云企业级落地、火山引擎 Anthropic 指南、12-Factor Agents、OpenAI 构建智能体 |
| 02 工具设计 | 阿里云工具基类与结构化输出、OpenAI 工具类型与指令 |
| 03 上下文与记忆 | 李乾坤博客 RAG/工作流相关、Contextual Retrieval 与 RAG 进阶 |
| 04 长任务与多 Agent | 李乾坤 Multi-Agent、阿里云状态与日志、多 Agent 编排实践 |
| 05 评测与 Evals | ICLR Agent Evaluation、HAL、Maxim 框架对比、Efficient Coder 指南、Tessl 8 benchmarks |
| 06 安全与生产 | 阿里云异常兜底与 Debug、12-Factor 运维与配置 |
参考文献(本页所列非官方来源)
| # | 来源 | 链接 |
|---|---|---|
| 1 | 53AI,2025 Agent 设计范式全解析 | https://www.53ai.com/news/LargeLanguageModel/2025110705248.html |
| 2 | 阿里云,企业级 LLM Agent 工程化落地实践 | https://developer.aliyun.com/article/1708881 |
| 3 | 火山引擎,Anthropic 架构设计与实践完全指南 | https://developer.volcengine.com/articles/7540133820868067370 |
| 4 | 李乾坤,LLM Agent 实践 | https://qiankunli.github.io/2024/09/13/llm_agent_practice.html |
| 5 | 小七洞,OpenAI 构建智能体指南(中文) | https://www.xiaoqiedun.com/posts/2025-04-18-a-practical-guide-to-building-agents/ |
| 6 | 12-Factor Agents 中文 | https://github.com/yzfly/12-factor-agents-zh |
| 7 | OpenAI,Building agents | https://platform.openai.com/docs/guides/agents |
| 8 | ICLR Blogposts 2026,Agent Evaluation | https://iclr-blogposts.github.io/2026/blog/2026/agent-evaluation/ |
| 9 | arXiv,Holistic Agent Leaderboard (HAL) | https://arxiv.org/abs/2510.11977 |
| 10 | Maxim,Agent Evaluation Frameworks Survey | https://www.getmaxim.ai/blog/llm-agent-evaluation-framework-comparison/ |
| 11 | Efficient Coder,AI Agent Evaluations 2025-2026 Guide | https://www.xugj520.cn/en/archives/ai-agent-evaluations-guide-2025.html |
| 12 | Tessl,8 benchmarks for AI agents | https://tessl.io/blog/8-benchmarks-shaping-the-next-generation-of-ai-agents/ |
转载自CSDN-专业IT技术社区
原文链接:https://blog.csdn.net/weixin_40959890/article/details/158319787



