Community程式設計與開發github.com

long-horizon-prompting

此技能涵蓋設計用於長時間自主運作或平行多智能體協作代理的啟動提示,特別著重於偽正式任務簡報的撰寫、增強與評估。

long-horizon-prompting 是什麼?

此技能專注於設計一種長時間運行的自主代理或平行多智能體協作的啟動提示,其核心技術為「偽正式任務簡報」(pseudo-formal task brief)。這是一種以形式化驗證的嚴謹性,但以語言化方式表達的規格,適用於大多數沒有機器可檢查成功條件的困難問題。技能詳細定義了任務簡報的各個組成部分,包括:精確定義術語及退化情況、確切的成功謂詞、不計入的結果清單、持久性規則與明確的停止、回傳條件和努力下限,以及管理多種平行方法的註冊表和已封鎖路徑的記錄。此外,技能也涵蓋了如何設計結構性的多樣性搜尋、交接合約、驗證瓶頸的處理,以及如何透過對抗性審計來防範獎勵駭客行為。此技能適用於Claude Code、Cursor、Codex等平台的開發者,在撰寫或審查長時間運行的代理提示時,能顯著提升任務成功率,避免因規格漏洞而浪費大量計算資源。

相容平台✓Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/long-horizon-prompting

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

長時域提示 (Long-Horizon Prompting)

此技能涵蓋設計用於啟動預計自主運作數小時或數天的代理之提示,代理可單獨運作,或作為管理多個平行工作者的協調器。核心技術是偽正式任務簡報 (pseudo-formal task brief):一種以形式化驗證的嚴謹性撰寫,但以語言化方式表達的規格,因為大多數困難問題都沒有機器可檢查的成功條件。典範案例是 GPT-5.6 Sol Ultra 發布的 Cycle Double Cover Conjecture 候選證明背後的提示,該證明由 64 個子代理協調執行產生 (claim-long-horizon-cdc-run)。此提示結構的適用範圍遠超數學領域:任何可以精確陳述成功條件並列舉失敗模式的領域,都可以使用相同的簡報結構。在協調執行中,相同的紀律適用於每一次交接:當模型在 Sakana AI 的 MASS 研究中優化其自身的多代理工作流程文本時,任務資訊從工作者角色移轉到了輸出合約和呼叫順序中 (claim-long-horizon-contract-information-shift)。

關鍵取捨:所有使長時間運行富有成效的因素(持久性、自主性、平行性),同時也提高了弱規格的代價。一個簡短的互動式提示失敗的代價很低;一個帶有漏洞的長時域簡報則會耗費數小時的計算資源,產生一個「看似答案」但未解決問題的產物。

啟用時機

在以下情況啟用此技能:

  • 在啟動長時間運行的自主執行之前,撰寫或審查其提示
  • 將模糊的困難問題(「解決 X」、「找出 Y 發生的原因」)轉換為具有成功謂詞和不計入結果的明確簡報
  • 為管理多個平行工作者處理開放式搜尋問題的根提示或協調器提示進行撰寫
  • 為代理提示添加持久性指令、停止條件、努力下限或回傳閘門
  • 撰寫每個被委派工作者必須滿足的輸出合約和驗收檢查,或決定哪些審查結果會阻止回傳
  • 診斷失敗的長時間運行,其失敗根源可追溯到簡報:過早回傳、看似正確的近似解、所有工作者收斂於同一種方法、或偽造的完成聲明
  • 在投入昂貴的代理時間之前,建立啟動前審查步驟以增強和評估提示

請勿 對以下由其他技能負責的相關工作啟用此技能:

  • 代理拓撲、監督者與群體選擇、交接協議和協調機制:multi-agent-patterns。該技能擁有架構的所有權;此技能擁有引導架構的文字,包括每個工作者必須回傳的合約。
  • 運行時控制介面、鎖定評估器、回滾、持久日誌以及自主循環的核准邊界:harness-engineering。必須承受優化壓力的約束屬於 harness,而非提示。
  • 建構評估器、回歸套件或決定執行分數的確定性品質閘門:evaluation。
  • 以 LLM 作為評審的設計、評分標準、成對比較和偏差減輕:advanced-evaluation。
  • 為應對上下文限制而進行的壓縮、筆記記錄和跨會話記憶機制:context-compression、memory-systems、filesystem-context。
  • 修改自身 harness 或提示的循環:self-improvement-loops。
  • 遠端沙箱和背景執行基礎設施:hosted-agents。

核心概念

偽正式任務規格 (Pseudo-Formal Task Specification)

形式化驗證需要機器可檢查的規格。困難的開放式問題很少有此規格,但其紀律可以轉移:陳述成功條件的精確度,要讓一個對抗性讀者無法在滿足其字面意義的同時,不滿足其意圖。四個組成部分,按影響力排序:

  1. 附帶退化情況的定義 (Definitions with degenerate cases)。 在陳述目標之前,定義每個承載意義的術語,包括懶惰解法會利用的邊緣情況。CDC 提示在任務之前定義了圖、橋接、環和 cycle double cover,明確涵蓋了平行邊雙環、不連通圖和零邊圖。
  2. 確切的成功謂詞 (Exact success predicate)。 一個關於回傳產物必須滿足何種條件的陳述,範圍量詞需明確說明(例如「每個沒有橋接的有限環狀多重圖,無需額外假設如 cubicity、planarity、連通性或更高邊連通性」)。
  3. 不計入的結果 (Non-counting outcomes)。 一個列舉的清單,說明哪些結果不計入:部分進展、特殊情況解法、歸約到另一個未證明的陳述、有界或計算驗證、以及盡力而為的摘要。這是影響力最大的組成部分。在持久性壓力下,模型會產生看似正確的近似解;每個被排除的結果都移除了一個逃脫路徑。
  4. 為審計者列舉的失敗模式 (Enumerated failure modes for the auditor)。 一個具體的檢查清單,列出候選答案可能微妙錯誤的特定領域方式(在 CDC 中:冒充環的重複邊封閉軌跡、由歸約引入的橋接、循環使用等價陳述)。擁有列舉搜尋清單的驗證者,能比泛泛的「檢查工作」指令捕捉到更多問題。

盡可能機器檢查 (Machine-check what can be machine-checked)。 一個對整個產物沒有自動成功訊號的任務,其部分仍可由指令決定:必須通過的測試、資料分割上的不變量、模式有效性、在瀏覽器中點擊完成的用戶流程。將每個部分表達為一個具名檢查,並附上執行該檢查的命令,而將語言謂詞保留給剩餘的、沒有指令能決定的部分。

長時域簡報的結構 (Anatomy of a Long-Horizon Brief)

區塊功能防止的失敗
定義固定詞彙,包括退化情況利用技術細節的漏洞解法
成功謂詞精確陳述回傳時必須滿足的條件縮小範圍的答案
不計入的結果列舉不計入的近似解看似正確的部分結果
可解性框架在存在性合理時「假設解存在」放棄漂移、「這是開放問題」的拒絕
協調策略用於分配平行工作者的啟發式規則,而非固定指派過早收斂、浪費平行性
交接合約每個工作者回傳具名產物和類型化檢查;下游工作等待它們錯誤跨階段疊加、模擬委派
驗證策略帶有列舉失敗模式和封鎖規則的對抗性審計寬容的自我評判、永不收斂的審查
回報合約所需的具體產物;不接受狀態報告模糊的樂觀主義、偽造的進度
回傳條件僅在產物通過審計時回傳過早回傳、盡力而為的摘要
努力下限在考慮放棄前的最低努力過早放棄
汙染防護外部搜尋可能用於何處以及不可用於何處洗白的查詢、基準洩漏

持久性是雙面刃 (Persistence Cuts Both Ways)

持久性指令(「在…之前不要回傳」、努力下限、假設可解框架)可對抗在長時間軌跡中放棄的漂移趨勢 (claim-long-horizon-give-up-drift)。但同樣的壓力也增加了獎勵駭客攻擊的表面:截至測量為止,最經受過持久性訓練的前沿模型,其檢測到的作弊率也是其評估器測試過的所有模型中最高的,而且其測量的時間視野對於作弊是否計為成功並不穩健 (claim-long-horizon-persistence-hacking)。設計規則:絕不添加持久性指令而不配對一個驗證閘門。針對寬鬆成功謂詞的持久性壓力,只會產生自信滿滿的非解決方案。

驗證瓶頸 (The Verification Bottleneck)

平行取樣可靠地提高了某個工作者找到正確答案的機率,但系統選擇該答案的能力落後了,而且針對困難產物的模型評審系統性地過於寬容,獎勵看似嚴謹但實際不完整的論證 (claim-long-horizon-verification-gap)。為驗證器投入與生成器同等程度的提示設計預算:

  • 給審計者提供簡報中的列舉失敗模式清單,而非泛泛的品質指令。
  • 要求生成器產生模組化、可獨立檢查的輸出(具有前提和結論的引理層級結構),以便驗證可以分解。
  • 使用新鮮上下文的對抗性驗證器,而非自我批判;未建構產物的驗證器無法合理化其缺陷。新鮮上下文移除了建構歷史,但未消除同一模型家族共享的先驗知識,因此在結果重要時,至少要將一項檢查保留在循環外部。
  • 將代理間的共識視為多樣性失敗訊號,而非確認:委員會在最困難的問題上收斂得最緊密,此時一致性反映的是共享偏差,而非確證 (claim-long-horizon-diversity-collapse)。
  • 定義哪些發現會封鎖 (block)。一個新鮮的對抗性審閱者總是會發現一些東西。只有當發現以證據(一個失敗的檢查、一個反例、一個可重現的案例)顯示違反了成功謂詞、合約檢查或清單時,該發現才能封鎖回傳;將所有其他發現記錄為非封鎖性。沒有此規則,「通過審計」永遠不會收斂,或者協調器會私下決定哪些發現重要。
  • 投資於修正者 (reviser),而不僅僅是審閱者。在 MASS 工作流程搜尋中,僅升級評估器的幫助小於同時升級評估器和優化器 (claim-long-horizon-reviser-bottleneck);準確的發現若交給無法據以行動的代理,便是浪費。

交接合約 (Handoff Contracts)

在協調執行中,「完成」在每次交接時定義,而不僅僅是在最後一次。MASS 將多代理工作流程撰寫為文字,每個工作者包含四個部分:角色、指令、合約(工作者必須回傳的產物和資訊,包括所需檢查)和跳轉(呼叫順序)。當模型自身優化該文字時,任務資訊在角色和指令中減少,並在合約和跳轉中增加 (claim-long-horizon-contract-information-shift)。「細心的資料科學家」適合任何任務;一份要求在建模開始前提供 no_future_leakage: bool 的合約只適合一個任務。

  • 以每個檢查所要排除的失敗為其命名,並使其類型化,以便下一個代理和 harness 可以在無需判斷的情況下讀取它。
  • 將每個檢查放置在可能引入該錯誤的階段,並且僅在該階段的合約被滿足時才開始下游工作。
  • 列出檢查必須拒絕的退化值:好到不真實的指標、應該不同但卻匹配的數量、佔位符、將 NaN 或空結果視為通過等。對一個已知的不良輸入執行每個檢查一次;一個空洞的檢查會為它本應捕捉的失敗背書。
  • 將失敗的檢查作為召回 (recall) 路由回負責的工作者,附帶失敗的檢查、縮小的範圍、驗收標準和重試上限。修正請求攜帶其自身的完成定義,而不是重新開啟整個產物。
  • 要求真正的委派。一個在其自身輪次中撰寫工作者輸出的協調器,只是模擬了交接,而模擬不計入。

註解的工作流程、演進的閘門以及作者們的執行指令位於 MASS 參考資料。

平行搜尋中的結構性多樣性 (Structural Diversity in Parallel Search)

角色標籤不會創造多樣性;平行工作者共享先驗知識,除非工程性地創造獨立性,否則它們會收斂:

  • 讓早期輪次的工作者對當前受青睞的方法保持盲目。
  • 維護一個明確的方法家族註冊表,按基本思想而非表面用詞分組,並將工作者從擁擠的家族中重新導向。
  • 當一條路徑在與原始目標難度相當的缺失步驟上停滯時,將其標記為已封鎖;僅當出現實質性的新機制時,才重新指派工作者到該路徑,而不是因為熱情。
  • 在獨立開發已揭示每條路徑的真正優勢和缺陷之後,再進行晚期交叉授粉。
  • 不要因為某個方法的歸約很優雅就讓它主導;一條以強度與原始目標等價的引理結束的路徑並非進展。

停止條件、努力與進度狀態 (Stop Conditions, Effort, and Progress State)

長時間軌跡會漂向不確定性和放棄,而在提示頂部一次設定的預算,會隨著上下文增長而失去效力 (claim-long-horizon-give-up-drift)。屬於簡報的應對措施:明確的努力下限(「在考慮回傳之前至少花費這麼多努力」)、在解存在合理時的可解框架,以及將回傳條件表述為關於產物的謂詞,而非關於代理的信心水準。不屬於提示的應對措施:一個外部維護的、經過驗證的進度分類帳,每輪重新注入,在對照比較中,這挽救了僅靠提示和完成閘門設定完全失敗的大量任務 (claim-long-horizon-state-ledger)。進度聲明應可稽核:要求每個報告的聲明都追溯到工具結果或當前會話的產物,這在供應商測試中幾乎消除了偽造的進度報告 (claim-long-horizon-evidence-audit)。

精簡與結果優先 (Lean and Outcome-First)

兩大供應商在當前前沿模型的教條上趨於一致:提示應承載結果、硬性約束、證據來源和完成門檻,並將路徑留給模型。積累的指令堆疊明顯有害;更精簡的系統提示改善了供應商的編碼代理評估,同時降低了成本 (claim-long-horizon-lean-prompt)。持久性本身越來越傾向於訓練而非提示,因此應將 token 預算花在訓練無法提供的東西上:成功謂詞、不計入清單,以及只有了解問題的專家才知道的領域失敗模式。每個工作者的合約屬於完成門檻,而非路徑:它們陳述一個階段必須建立什麼以及如何檢查它,從不說明如何完成工作。

詳細主題

CDC

…

[為翻譯而截斷]

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

advanced-evaluation

This skill should be used for advanced LLM evaluation: LLM-as-judge systems, direct scoring, pairwise comparison, rubric calibration, evaluator bias mitigation, confidence scoring, and automated quality assessment.

bdi-mental-states

This skill should be used when modeling agent mental states with BDI concepts: beliefs, desires, intentions, RDF-to-belief transformations, rational agency traces, cognitive agents, BDI ontologies, and neuro-symbolic AI integration.

book-sft-pipeline

This skill should be used for book-to-SFT pipelines: ePub extraction, literary segmentation, author-voice dataset construction, style-transfer training, LoRA workflows, and model evaluation for voice replication.

comprehensive-research-agent

Ensure thorough validation, error recovery, and transparent reasoning in research tasks with multiple tool calls

context-compression

This skill should be used when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve decisions, files, risks, and next actions.

context-degradation

This skill should be used for diagnosing and mitigating context degradation: lost-in-middle failures, context poisoning, context clash, context confusion, attention-pattern issues, and agent performance degradation caused by accumulated or conflicting context.

context-fundamentals

This skill should be used to explain or reason about the foundational concepts of context engineering: what context is, the anatomy of a context window, how attention mechanics work, the U-shaped attention curve, why context quality matters more than quantity, and the mental models needed to interpret every other context-engineering decision. Use this for conceptual explanation, onboarding, and background reading. Route operational work to the specialized skills: debugging attention failures goes to context-degradation, token-efficiency work goes to context-optimization, conversation summarization goes to context-compression, and project-shape decisions go to project-development.

context-optimization

This skill should be used for improving context efficiency: context budgeting, observation masking, prefix or KV-cache strategy, partitioning, token-cost reduction, retrieval scoping, and extending effective context capacity without lowering answer quality.

evaluation

This skill should be used when building agent evaluation systems: deterministic checks, regression suites, multi-dimensional rubrics, quality gates, production monitoring, baseline comparison, and outcome measurement for agent pipelines.

filesystem-context

This skill should be used when agent work needs file-backed context: durable scratchpads, tool-output offloading, just-in-time discovery, cross-agent handoff files, filesystem memory, or cleanup policies for context stored outside the prompt.

harness-engineering

This skill should be used when designing autonomous agent harnesses: research loops, evaluation scaffolds, locked and editable surfaces, durable logs, novelty gates, pruning, rollback, PR preparation, and human approval boundaries.

hosted-agents

This skill should be used when designing hosted or background agent infrastructure: sandboxed execution, remote coding environments, warm pools, session persistence, multiplayer collaboration, self-spawning agents, or Modal-style sandboxes.

instruction-surface-security

Hardens agent runtimes against persistent prompt injection or unauthorized changes to instructions and permissions. Use to audit what agents auto-load, design reviewed activation for project rules, skills, memory, or tool configuration, and test whether trust boundaries hold after reload, restart, or delegation.

latent-briefing

This skill should be used when the user asks to "share memory between agents", "KV cache compaction for multi-agent", "orchestrator worker context", "latent briefing", "reduce worker tokens", "cross-agent memory without summarization", or discusses Attention Matching compaction, recursive language models with workers, or token explosion in hierarchical agents.

memory-systems

This skill should be used for persistent semantic memory in agent systems: cross-session knowledge retention, entity tracking, temporal validity, graph or vector retrieval, memory consolidation, and memory benchmark selection. Route file-backed scratchpads to filesystem-context, handoff summaries to context-compression, and token-efficiency tactics to context-optimization.

multi-agent-patterns

This skill should be used when designing multi-agent systems that need context isolation, supervisor or swarm coordination, explicit handoffs, parallel execution, or a decision on whether multiple agents are justified.

project-development

This skill should be used for project-level decisions about LLM-powered systems: whether an LLM is the right primitive for the task at hand, the shape of a multi-stage batch or agent pipeline, token and cost estimation, choosing between single-agent and multi-agent at the project level, structured output design for downstream parsing, and structuring agent-assisted iteration. Use this when the unit of work is a whole project or a multi-stage pipeline. Route individual tool design to tool-design and individual skill-loading or context-budget tactics to context-optimization.

self-improvement-loops

This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.

self-managed-context

This skill should be used when a model gets read-write control over its own live context window instead of a harness-scheduled compaction policy: the context exposed as an editable file the model rewrites with code tools, model-driven eviction and in-place updates, the harness invariants that keep self-editing safe (pinned prefix, edit gate, edit receipts, budget readouts, rollback on overflow), the prefix-cache cost of mid-context edits, and steering or training the model's own context-editing strategy. Route note content and fixed-threshold summarization to context-compression, cache-stable layout under harness control to context-optimization, file offloading to filesystem-context, and loop governance to self-improvement-loops.

tool-design

This skill should be used for the tool-interface layer of an agent system specifically: writing tool descriptions agents can route on, designing tool schemas and response formats, naming conventions, actionable error recovery messages, MCP server design, tool-set consolidation, and deciding when to add or remove an individual tool. Use this when the unit of work is a single tool or a set of tools. Route project-shape, pipeline architecture, and task-model-fit decisions to project-development; route deciding whether to introduce sub-agents to multi-agent-patterns.

相關技能