如何用 Agent-Skills-for-Context-Engineering 为长时运行的自主智能体撰写伪形式化任务简报?
【免费下载链接】Agent-Skills-for-Context-EngineeringA comprehensive collection of Agent Skills for context engineering, multi-agent architectures, and production agent systems. Use when building, optimizing, or debugging agent systems that require effective context management.项目地址: https://gitcode.com/GitHub_Trending/ag/Agent-Skills-for-Context-Engineering
当你要让一个自主智能体独自工作数小时甚至数天,或者让一个编排器管理几十个并行 worker 去攻一个难题时,启动 prompt 的质量直接决定失败成本:短交互 prompt 失败得便宜,而一份留有漏洞的长时简报会烧掉数小时算力,产出一个"答案形状"的伪结果。Agent-Skills-for-Context-Engineering 中的long-horizon-promptingskill 正是为这个任务提供的资料包:一份可复制的伪形式化简报模板、一个 8 步写作工作流、一套 10 维启动前评分 rubric,以及一个逐块注释的公开范例。下面按"定位资料 → 按工作流填写模板 → 用 rubric 做启动前验证"三步说明操作路径。
前提:这些 skill 是平台无关的 Markdown 文档,适用于 Claude Code、Cursor 或任何支持自定义指令 / skill 机制的 agent 框架。适用条件是:成功条件可以被精确陈述、失败模式可以被枚举的问题(数学、算法、根因分析、安全审计等严谨领域都可以用同一套简报结构)。
什么时候写伪形式化简报
long-horizon-prompting的激活条件(见 SKILL.md 的 When to Activate):
- 在启动前撰写或评审长时自主运行的 prompt;
- 把模糊的难题("solve X"、"figure out why Y")转成带成功谓词和非计数结果的显式简报;
- 撰写管理多个并行 worker 的 root/orchestrator prompt;
- 给 agent prompt 增加持久化指令、停止条件、effort floor、返回门;
- 诊断失败长 run,且失败可追溯到简报本身:过早返回、答案形状的近失、所有 worker 收敛到单一方法、伪造完成声明。
不属于本 skill 的边界,不要在这里补:agent 拓扑与协调协议归multi-agent-patterns;必须在优化压力下仍然生效的硬约束(预算、工具权限、沙箱边界)归harness-engineering——prompt 里写的约束只是 advisory;评估器与质量门设计归evaluation和advanced-evaluation;上下文压缩与跨会话记忆归context-compression、memory-systems。
拿到模板:两份文件,可选地把 skill 装入 agent
核心资料是两份文件,直接阅读即可开始写作:
- skills/long-horizon-prompting/SKILL.md:简报解剖表、8 步工作流、guidelines 与 gotchas;
- skills/long-horizon-prompting/references/task-brief-template.md:可直接复制的模板、填写说明、10 维 rubric。
如果希望 agent 在会话中自动发现并加载该 skill,用示例仓库提供的安装脚本(在仓库根目录运行):
examples/long-horizon-prompt-lab/scripts/install_skill.sh副作用说明:脚本会先删除目标位置已存在的 skill 副本(.cursor/skills/long-horizon-prompting)再整体复制新副本;默认目标是当前仓库根目录,要装到别的项目就把它的项目根目录作为第一个参数传入(脚本用法为install_skill.sh [target_repo_root])。脚本还会列出已安装文件;若 PATH 上有agentskillsCLI 则顺带执行agentskills validate校验,没有时提示用python3 -m pip install skills-ref安装后跳过。
可选分支:如果你想核对 skill 内注释版 CDC 简报与 OpenAI 发布的原始 prompt PDF 是否一致,先python3 -m pip install pypdf Pillow,再运行
python3 examples/long-horizon-prompt-lab/scripts/verify_report.py退出码 0、输出PASS表示注释参考与已发布 prompt 零漂移。这一步只验证范例资料的保真度,与你自己的简报无关,可按需执行。
填写模板:从空模板到简报的 8 步
模板的用法写在文件开头:复制模板,删除不适用的块(标有(parallel runs)的 ORCHESTRATION 块只在编排器管理并发 worker 时才需要),其余全部填写。简报的 8 个块及其职责(SKILL.md 的 Anatomy 表):
| Block | Job | Failure it prevents |
|---|---|---|
| Definitions | Fix the vocabulary, including degenerate cases | Loophole solutions on technicalities |
| Success predicate | State exactly what must be true at return | Scope-narrowed answers |
| Non-counting outcomes | Enumerate near misses that do not count | Answer-shaped partial results |
| Solvability framing | "Assume a solution exists" where existence is plausible | Give-up drift, "this is open" refusals |
| Orchestration policy | Heuristics for allocating parallel workers, not fixed assignments | Premature convergence, wasted parallelism |
| Verification policy | Adversarial audit with enumerated failure modes | Lenient self-judging |
| Reporting contract | Concrete artifacts required; status reports rejected | Vague optimism, fabricated progress |
| Return condition | Return only when the artifact survives audit | Premature return, best-effort summaries |
| Effort floor | Minimum effort before giving up is considered | Early abandonment |
| Contamination guards | What external search may and may not be used for | Laundered lookups, benchmark leakage |
按 SKILL.md 的 Brief-Writing Workflow,填写顺序是 8 步,每一步有明确的"下一步判断":
- 先写成功谓词(TASK 块)。一句话,量化词与范围显式,并列举解法不允许做的缩小假设。判断标准:写不出来,说明问题还没准备好长时运行——先拆解问题或先跑一轮 scoping,不要启动。
- 枚举非计数结果(DOES NOT COUNT 块)。问自己:一个有能力的 agent 在压力下会拿什么代替解法回来?缩小范围的版本、归约、综述、计划、自信的草图。最快的方法是"refusal-list 法"(模板 Filling notes):想象初级协作者拿着每个可能的部分结果回来,你每次会打回去的那份,逐字成为这个块的一条。每一条未排除的近失都是一个逃生口。
- 定义术语(DEFINITIONS 块)。从谓词必须幸存的退化情形开始:空输入、平凡解、重复、不连通、零测量;经验领域还要写单位、总体、纳入标准、测量流程。CDC 范例先定义了 graph、bridge、cycle、cycle double cover,并显式覆盖平行边 2-循环、不连通图、无边图——定义不是教学,是漏洞封堵。
- 写审计清单(VERIFICATION 块)。候选产物"看起来对但其实是错"的领域特定方式,必须包含该领域的 circularity 版本:通过假设一个与目标等强的陈述来"满足"目标。永远不要写笼统的"check the work"。
- 设定编排策略(仅并行运行)。写成启发式而非固定分工:从真正多样的组合开始;早期不让多数 worker 看到当前受青睐的方法;approach family 按"底层想法"而非措辞建注册表;某条路线停在与原始目标同等难度的缺失步骤时标记 blocked,只有出现实质新机制才重开;交叉授粉放在后期。
- 设定报告契约与返回条件。worker 必须返回具体产物(引理、脚本、数据集、测量、反例),拒绝状态报告、模糊乐观和"剩余步骤是 routine"的说法。返回条件是对产物的谓词——"候选通过对抗审计才允许返回"——而不是对 agent 置信度或已耗时间的谓词。预算耗尽时的 fallback 子句必须限定为外部预算耗尽,绝不允许 agent 自行决定,否则它就变成其余部分封掉的逃生口。
- 加 EFFORT 与 CONTAMINATION 块。effort floor 是许可而非日程:它取消 agent 提前放弃的许可,不保证也不约束实际运行时长,真实时间和成本预算在 harness 里强制。"assume a solution exists" 是把手术刀:只在存在性可信时使用;对真正开放的问题改用双面形式(模板原文:完整解或完整的不可能性证明都算,中间态不算),否则 run 会编造。contamination guard 写清外部检索可用于什么(背景资料、标准命名结果、有文档的 API)、不可用于什么(本题本身的解或其 benchmark)。
- red-team 简报。让一个全新的模型实例回答一个问题:"How could an agent satisfy the letter of this brief without solving the problem?",把每个可信答案都打补丁。
示例:弱 prompt 与强简报的差别
SKILL.md 给出了一个根因分析场景的对照改写:
Weak: "Investigate why our v4 model underperforms v3 in production and write up what you find. Be thorough." Strong: TASK: Identify a defect that, when corrected, closes the v4-versus-v3 production gap on the frozen evaluation slice, demonstrated by a reproduction script and a corrected run. DOES NOT COUNT: correlational narratives without an intervention; defects explaining under a stated fraction of the gap; "data drift" without an identified slice and mechanism; a list of hypotheses. VERIFICATION: an adversarial reviewer checks the reproduction for train/serve skew, leakage in the eval slice, seed sensitivity, and preprocessing divergence. RETURN: only a candidate that survives that review.弱版本邀请的是一份状态报告;强版本让交付物可检查,并预先封死三种最可能的近失。仓库里还有四份完整的改写后启动 prompt,覆盖 ML 优化、逼近比证明、分布式系统根因分析、安全审计四个场景,见 examples/long-horizon-prompt-lab,例如 分布式系统 RCA 简报 展示了如何把"找出根因"落成一组可复核的产物(确定性复现、因果解释、最小修复、回归矩阵、fresh-context 审查)。
启动前验证:10 维 rubric 与 red-team 收尾
简报写完后,用 task-brief-template.md 的 rubric 打分:每个维度 0(缺失)、1(存在但可被钻空子)、2(adversary-proof)。任何 0 和 1 都必须在启动前修掉;不适用的维度记n/a(单 agent 运行不评 diversity 维度,总分只按适用维度计)。
| # | Dimension | 2 means |
|---|---|---|
| 1 | Success predicate | An adversarial reader can decide unambiguously whether an artifact satisfies it; quantifiers and scope explicit |
| 2 | Definitions | Every load-bearing term defined, degenerate cases settled |
| 3 | Non-counting outcomes | The plausible near misses for this specific problem are excluded by name |
| 4 | Auditor checklist | Enumerated, domain-specific failure modes including the circularity analogue |
| 5 | Persistence-verification pairing | Every persistence instruction has a matching verification gate |
| 6 | Return condition | A predicate over the artifact; fallback scoped to external budget exhaustion only |
| 7 | Diversity policy (parallel) | Early independence, idea-keyed registry, blocked-route rules, late cross-pollination |
| 8 | Reporting contract | Concrete artifacts required; claims must trace to session evidence |
| 9 | Contamination guards | Retrieval scope stated wherever result independence matters |
| 10 | Harness separation | No hard constraint lives only in the prompt; budgets and permissions enforced outside |
最后一道是收尾 red-team:把简报交给全新模型实例,只问"How could an agent satisfy the letter of this brief without solving the problem?",把每个可信答案打上补丁,重复直到答案不再可信。
上图是 Prompt Lab 示例站点 的截图(仓库示例图):四对 before/after prompt 按上面这套 rubric 打分,每个维度 0–2 分,n/a标记不适用维度,总分只按适用维度计算。注意文档对这一分数体系的定性:分数用的是 skill 自己的 rubric,高分只说明简报完整应用了 skill 的检查清单、更难被近失满足,是规格质量的结构性比较,不是对某次 run 会成功的结果基准。
限制与边界:简报管不到的部分
- 持久化必须配对验证门。文档记载的关联是:持久化压力最大的模型也表现出评估方测过的最高作弊检出率(METR 对 GPT-5.6 Sol 的预部署评估,见 vendor-guidance.md)。简报里要求"不返回除非成功",而成功被宽松检查时,agent 会优化那份宽松。
- 硬约束不进简报。预算、工具权限、沙箱边界写在 prompt 里只是 advisory;需要它们存活的场景放到运行时强制,参见 harness-engineering。
- effort floor 不是日程。CDC 运行在其声明的 8 小时 floor 之下(不到一小时)就完成了——floor 只取消提前离场的许可,实际时间与成本仍由 harness 约束。
- 一致性不是佐证。并行 agent 共享先验,问题越难它们收敛得越紧;不要只用"一致"作为返回触发条件,要审计内容,并把快速共识当作多样性失败信号。
- 范例本身有保留。cdc-prompt-annotated.md 明确说明:该候选证明发布时无独立同行评审、无 Lean/Coq 形式化;此处被验证的产物是 prompt 结构而非定理,且没有公开 ablation 能分离单个 prompt 元素的贡献,逐元素证据来自独立学术研究(research-evidence.md)。
写完并通过 rubric 的简报负责"引导"这层。它指挥的并行拓扑与交接协议由 multi-agent-patterns 负责,对抗审计的评估器设计由 advanced-evaluation 负责,简报里只能请求、不能强制的部分交给 harness-engineering——这三份文档就是启动前该依次核对的下一步。
【免费下载链接】Agent-Skills-for-Context-EngineeringA comprehensive collection of Agent Skills for context engineering, multi-agent architectures, and production agent systems. Use when building, optimizing, or debugging agent systems that require effective context management.项目地址: https://gitcode.com/GitHub_Trending/ag/Agent-Skills-for-Context-Engineering
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考