📜 软件简史与 AI Agent 演进

基于 12-factor-agentsbrief-history-of-software.md 要点梳理 第一性原理 · 微Agent · DAG演进

🎯 一、核心观点:重新思考 AI Agent

📅 二、软件历史的三阶段

时期特点
60 年前软件表现为流程图,本质上是有向图(DG)或有向无环图(DAG)。
20 年前DAG 编排器兴起(如 Airflow、Prefect、Dagster),增加可观测性、模块化、重试等。
10-15 年前ML 模型开始融入 DAG(如“摘要列”、“分类问题”),但仍是确定性软件。

⚖️ 三、Agent 的“承诺”与现实问题

✅ 承诺

🔄 Agent 作为循环(Loop)

初始上下文 → LLM 决定下一步(工具调用)→ 确定性代码执行 → 结果加入上下文 → 重复,直到标记“完成”

伪代码示意:

while True:
  next_step = llm.determine_next_step(context)
  if next_step.intent == "done": return final_answer
  result = execute_step(next_step)
  context.append(result)

❌ 核心问题

🧩 四、实际有效方案:微Agent(Micro Agents)

模式

Agent 模式“洒入”更大的确定性 DAG 中。每个微 Agent 只负责范围很小的任务,由确定性代码调度。

📌 示例:部署流程中的微Agent

  1. 确定性代码:合并 PR → 部署到 staging → 跑端到端测试。
  2. 交给 微 Agent 负责生产部署(初始上下文:“部署 SHA 4af9ec0”)。
  3. Agent 调用 deploy_frontend_to_prod → 确定性代码请求人工审批。
  4. 人类拒绝并反馈:“先部署 backend”。
  5. Agent 调用 deploy_backend_to_prod → 审批通过 → 执行。
  6. Agent 再调用前端部署 → 审批通过 → 执行。
  7. Agent 判断完成 → 确定性代码跑生产端到端测试。

✨ 关键价值

🧠 五、Agent 的真正组成(作者定义)

  1. 提示(Prompt):告诉 LLM 行为规则和可用工具,输出下一步的 JSON(工具调用)。
  2. switch 语句:根据 JSON 决定要做什么。
  3. 累积上下文:存储所有已执行步骤及其结果。
  4. for 循环:直到 LLM 发出“终端”信号,不断重复“决定→执行→追加上下文”。

🔧 额外收益(拥有控制流与上下文积累)

🔮 六、结论与预告

💡 补充提及:原文中涉及 factor 1, factor 3, factor 7, factor 8 等原则(如人工反馈、上下文隔离、控制流拥有权),在微Agent设计中贯穿体现。

📎 原文金句摘录

“having language models managing well-scoped sets of tasks makes it easy to incorporate live human feedback...without spinning out into context error loops.”
“Even as models support longer and longer context windows, you'll ALWAYS get better results with a small, focused prompt and context.”