← 返回首页

图灵学院AI大模型第5期全套课程百度网盘下载:第三阶段Agent智能体开发第5节更新(2026.11更新)

Agent 智能体开发 任务编排 SQLite Python

【微信642620018 或 1039576978,获取课程全套资料】

图灵学院 AI 大模型第5期走到第三阶段第5节,Agent 智能体开发这条线已经从「能不能调通工具」进入「能不能稳定跑完一串任务」。这一节更新后最值得补的课,是把 Agent 的任务状态显式存下来,让它挂掉能续、跑偏能退。下面按可落地的顺序写,代码可以直接拿去跑。

结论先给:别把状态藏在对话历史里。用一个可序列化的状态对象 + 一张 SQLite 表 + 每步两次落盘,就能把「一次性脚本」变成「可恢复的任务」,成本不到半天。

import json, sqlite3, time

conn = sqlite3.connect("agent_tasks.db")
conn.execute("""create table if not exists tasks(
  id text primary key, step integer, status text, state text, updated integer)""")

def checkpoint(task_id, step, status, state):
    conn.execute("insert or replace into tasks values(?,?,?,?,?)",
                 (task_id, step, status, json.dumps(state, ensure_ascii=False), int(time.time())))
    conn.commit()

def run_step(task_id, step, state, fn):
    checkpoint(task_id, step, "running", state)     # 开工前
    out = fn(state, idem_key=f"{task_id}:{step}")
    state["done"].append(step)
    state["outputs"][str(step)] = out
    checkpoint(task_id, step, "done", state)        # 完成后
    return state

常见坑:

小结:第5节之后的任务基本都会跨多步、跨进程,状态管理不是加分项而是地基。图灵学院这门课后面还会继续更新,我把每一节的推导和踩坑都记在同一份笔记里,跑不通的那一步可以拿日志来找我对。

参考链接:

https://vx642620018.top/articles/2026/11/30/1796054412609.html

https://cr7mufc520.cn/archives/kd-agent5-202611