# 用约 90 行无框架 Python 代码手写 agentic loop 搭建 AI Agent

- 原标题：Real Python 发布的一篇 AI Agent 开发教程：使用约90行 Python 代码，在不依赖任何 Agen…
- 类型：博客
- 来源：Real Python
- 发布时间：未知（待核验）
- 首次精选：2026-11-26 05:31
- 分级：值得看
- 是否付费：免费（全文公开可读）
- 预估学习时长：约 33 分钟（按全文字数估算）
- 学习层级：进阶
- 主题：[agent-context-memory](<https://oplearnx.com/md/topics/agent-context-memory.md>)（第 1 位）、[agent-architecture-harness](<https://oplearnx.com/md/topics/agent-architecture-harness.md>)（第 3 位）、[agents-tool-use](<https://oplearnx.com/md/topics/agents-tool-use.md>)（第 8 位）
- 原文链接：[https://realpython.com/agentic-loop](<https://realpython.com/agentic-loop>)
- 本站页面：[https://oplearnx.com/resources/pk\_68b2c6ebe54e](<https://oplearnx.com/resources/pk_68b2c6ebe54e>)

## 摘要

Real Python 的教程从一次失败的模型调用开始，逐步写出把语言模型变成 Agent 的 harness，全程约 90 行 Python 代码，不使用任何框架。教程讲解 Chat Completions API 不保存历史消息、因此每次请求需重发完整对话上下文，工具通过 JSON schema 描述参数、模型只返回 tool call 而由 harness 决定是否执行并回传结果，以及循环如何让模型串联多次工具调用。最终目标是让模型能探索未见过的文件夹并总结其内容。

## 推荐信源

- [蚁工厂](<https://weibo.com/2194035935/RsYM4FEea>)（2026-11-25）

---
来源：LearnMap · 学径（https://oplearnx.com）
