AI与Codex:完整实践与解答
需能阅读 Python 函数和 JSON 用例。本页从任务范围、上下文选择讲到验收;离线任务包用 format_label 的空白输入修复贯穿规则、候选补丁和审查表,不需要模型账号或 SDK。 示例未在本轮执行;本页完整源码与README列出输入、阅读顺序和预期。
Codex 完整任务包
Codex完整任务包包含AGENTS.md、任务说明、输入源码和验收表。示例未执行;它供人工检查任务是否足够明确,不实现代理或SDK,也不需要API密钥和网络。
Codex 验收练习
题目:代理只检查语法却写接口已恢复,怎样修改结论?
参考答案
改成语法解析通过,保留接口行为未验证,并列出未来需要的成功、失败与兼容场景。不要用换一个模型代替缺失证据。
Codex 任务恢复
Codex任务恢复先对比当前文件与已记录基线,重述未完成验收项,再继续最小修改。摘要不携带实际运行证据;清理只移除自己复制的练习文件,不删仓库规则或他人的变更。
完整源码、配置与输入
下列文件与仓库同源,包含完整实现和输入;不是运行证明。部分练习只需人工阅读配置,不强制构造模拟器。
AGENTS.md
markdown
# Offline exercise rules
Only edit formatter.py and review.md inside the copied exercise directory.
Goal: reject blank labels while preserving nonblank labels including Unicode.
Do not run any command, contact a model or use a network service.
Read task.md and cases.json before suggesting a patch.
Describe the exact behavior, evidence and remaining uncertainty.
Do not claim tests passed if they were only inspected.task.md
markdown
# Task contract
Input: one string label. before.py preserves the original implementation, which
only strips surrounding whitespace. formatter.py is the proposed candidate.
Required behavior: return trimmed label; raise ValueError for empty result.
Non-goals: do not normalize Unicode, change case or accept non-string input.
Allowed files: formatter.py, review.md. No dependency changes.
Review criteria: inspect empty, whitespace-only, ASCII and Chinese cases;
explain which existing behavior changes. Execution is prohibited in this lesson.formatter.py
python
def format_label(label: str) -> str:
trimmed = label.strip()
if not trimmed:
raise ValueError("label must not be blank")
return trimmedbefore.py(原实现)
python
def format_label(label: str) -> str:
return label.strip()cases.json
json
[
{
"input": " note ",
"expected": "note"
},
{
"input": " 学习 ",
"expected": "学习"
},
{
"input": " ",
"error": "ValueError"
},
{
"input": "",
"error": "ValueError"
}
]review.md
markdown
# Static review
Whitespace-only input reaches ValueError; Unicode content is retained.
No model was called and no example was executed. Type errors are outside contract.requirements.txt
text
# Python 3.11+ standard library only, for future reader use.
# No SDK, API key, model or network is required.项目README与完整依赖
README提供前置、完整自跑或阅读方式、预期、失败案例与恢复清理。本轮没有执行任何示例、产品CLI、模型或外部API。
markdown
# AI与Codex:完整教学包
示例未执行。全部输入为教学虚构资料,不能用于真实账号、生产数据或外部系统。
## 前置与依赖
无模型、SDK或账号;源码供Python3.11以上读者阅读。
## 文件与输入
- `AGENTS.md`:本包完整文件。
- `task.md`:本包完整文件。
- `formatter.py`:本包完整文件。
- `before.py`:仅去掉首尾空白的原实现;与候选formatter.py对照。
- `cases.json`:本包完整文件。
- `review.md`:本包完整文件。
- `requirements.txt`:本包完整文件。
## 读者将来自跑或阅读
复制本包所有文件到独立目录,在该目录作为当前工作目录。以下是读者自用资料,本轮禁止执行。
```text
本例只阅读AGENTS.md、task.md、formatter.py、cases.json和review.md,不提供模型调用命令。
```
## 正常预期
人工追踪空白输入会抛ValueError,中文标签保留;review明确无运行证据。
## 失败案例与恢复
若将if not trimmed误改成if not label,纯空白输入不会被拒绝;应由cases中空格项识别。
## 清理及能力边界
不得把规则文件中的禁止执行解释成API配置;清理只移除复制包。
## 来源
- [官方依据](https://developers.openai.com/codex/guides/agents-md)(2026-10-17资料核对;不是运行证明)依据与适用范围
- 本课官方依据,资料核对日2026-10-17。
本课完成的是列明任务的理论与静态资料,不代表产品全部能力或三平台运行通过。历史文档保留旧URL;涉及账号、版本、价格与界面位置时,以对应官方资料及实际授权环境为准。
本地能力核对:本会话工具清单确实提供本地文件与终端工具,权限由会话沙箱和用户约束控制;这不是所有Codex客户端都具备相同工具的保证。未调用模型、SDK或API。
继续阅读
- AI与Codex上手与对象
- AI与Codex上手与对象