逐日AI

面试题库

共 328 题,当前筛选 1 题。

Codex 与 OpenAI Agents SDK 高效使用

D1 Codex CLI 入门:安装、AGENTS.md、审批模式与沙箱、常用命令

  • 给 coding agent 写的项目说明文件(比如 Codex 的 AGENTS.md)应该写什么、不该写什么?为什么它要有大小上限?What belongs in a project instruction file for a coding agent (such as Codex's AGENTS.md), what does not, and why is there a size limit?
    国内高频海外高频基础#coding-agent#context#agents-md

    分析过程 · 先想清楚再作答

    1. 这题考的不是文件格式,而是你对「上下文是有限资源」有没有工程直觉。把它答成「写项目介绍」会被判为没真用过。
    2. 拆法是一个判断句:这条信息 agent 打开文件自己能不能发现?能发现的不写(目录结构、用了什么框架),发现不了的才写(约定、禁区、环境事实、测试命令)。
    3. 再补一层查找规则:全局层在用户目录,项目层从根目录到当前目录依次拼接,越靠近当前目录越靠后、越优先,所以子目录可以覆盖根规则。
    4. 大小上限(Codex 默认 32 KiB)的意义是逼你做取舍:手册太长会挤占任务本身的上下文,还会让模型对每一条规则的遵守度下降。
    5. 可预期的追问:写在说明文件里的规则模型一定会遵守吗?不一定,它是提示词的一部分,会被长对话稀释;硬约束要靠沙箱与审批,不是靠文字。

    How to reason about it · think before answering

    1. This probes whether you treat context as a scarce resource, not whether you know the file format; answering with a project overview signals inexperience.
    2. Use one test: can the agent discover this by opening files? If yes, leave it out (directory layout, framework); if no, write it down (conventions, no-go areas, environment facts, test commands).
    3. Add the lookup rules: a global file in the home directory, then project files concatenated from the repo root down to the current directory, so closer files override earlier ones.
    4. The size cap (32 KiB by default in Codex) forces prioritization: a long manual crowds out the task and dilutes adherence to every rule.
    5. Expect the follow-up: will the model always obey the file? No, it is prompt text and fades over long sessions; hard limits belong to the sandbox and approvals.

    答题要点

    • 写约定、禁区、环境事实和验证命令;不写 agent 自己打开文件就能发现的内容
    • 查找顺序是全局文件在前、项目文件从根到当前目录拼接,越靠近当前目录越优先
    • 大小上限逼你只保留高价值信息,避免挤占任务上下文、降低规则遵守度
    • 文字规则是建议性的,真正不能越的线交给沙箱与审批

    Key points

    • Write conventions, no-go areas, environment facts and verification commands; skip anything discoverable from the files
    • Lookup goes global first, then project files concatenated root-down, with closer files taking precedence
    • The size cap forces you to keep only high-value guidance so the task itself keeps its context budget
    • Instruction files are advisory; hard limits come from the sandbox and approval policy