Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add echoVic/blade-code --skill decision-loop-and-completiongit clone --depth 1 https://github.com/echoVic/blade-codeWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/echovic/blade-code/decision-loop-and-completion)<a href="https://agentmods.dev/skills/echovic/blade-code/decision-loop-and-completion"><img src="https://agentmods.dev/badge/skills/echovic/blade-code/decision-loop-and-completion.svg" alt="Measured on agentmods" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00145 | $0.02679 |
| Opus 5 | $0.00072 | $0.01340 |
| Sonnet 5 | $0.00029 | $0.00536 |
| Haiku 4.5 | $0.00015 | $0.00268 |
Grade A, and why
knowledge-agent-execution-and-orchestration-decision-loop-and-completion scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 75 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Module Structure
该节点描述一次 Agent run 如何在 Provider 回合、工具副作用、持久化和多重完成条件之间推进,并保证崩溃恢复后不会把未提交状态当成成功。
Directory Layout
packages/cli/src/agent/Agent.ts— 无状态入口、运行模式切换和 SessionRuntime 适配packages/cli/src/agent/ExecutionEngine.ts— ContextManager 容器与简单单轮执行兼容入口packages/cli/src/agent/ExecutionSummary.ts— 运行统计摘要packages/cli/src/agent/loop/— 主循环、会话状态、工具流、完成策略和恢复检测executeLoopGenerator.ts— 核心状态机StreamingToolExecutor.ts— 流式预启动、排队、顺序收集和 epoch 丢弃completionPolicy.ts— 显式委派、worktree、验证和停止策略conversationPersistence.ts— 消息、工具调用、工具结果和压缩的 durable commitindependentVerification.ts— 非平凡实现的独立验证门禁goalCompletionVerification.ts— Goal 完成候选门禁actionStationarity.ts— 重复工具动作的进展感知检测
packages/cli/src/prompts/— 默认提示、Plan 提示、项目指令和 Provider 边界附加内容packages/cli/src/services/StructuredOutputService.ts— JSON Schema 终态契约与恢复
Key Entry Points
Agent.chatStream()inpackages/cli/src/agent/Agent.ts— 统一事件流入口并处理 durable input、follow-up 与 Goal continuationexecuteLoopGenerator()inpackages/cli/src/agent/loop/executeLoopGenerator.ts— 完整 agentic loopStreamingToolExecutor.addTool()inpackages/cli/src/agent/loop/StreamingToolExecutor.ts— 决定流内预启动、排队或拒绝checkIndependentVerificationGate()inpackages/cli/src/agent/loop/independentVerification.ts— 主 Agent 独立验证准出createStructuredOutputContract()inpackages/cli/src/services/StructuredOutputService.ts— 结构化终态校验入口
Gotchas
stream_end是每个 Provider turn 的终止信号,一个完整 run 内可能出现多次;消费者不能把第一次stream_end当成 Agent 已完成 (packages/cli/src/agent/loop/types.ts)- 流式预启动同时要求工具在固定只读 allowlist、声明
isConcurrencySafe且前面没有 exclusive barrier;仅把工具标成并发安全不会让它在 Provider 流提交前启动 (packages/cli/src/agent/loop/StreamingToolExecutor.ts) - 工具副作用前必须先按模型调用顺序提交 durable
tool_call;required commit 失败时工具根本不启动,不能把返回的失败结果解释为“可能已执行” (packages/cli/src/agent/loop/StreamingToolExecutor.ts,packages/cli/src/agent/loop/conversationPersistence.ts) - 工具执行完成后仍要先提交 durable
tool_result才能发布给界面或下一次 Provider 请求;该提交失败时副作用可能已发生,loop 以tool_persistence_failed停止并要求恢复阶段处理不确定性 (packages/cli/src/agent/loop/executeLoopGenerator.ts,packages/cli/src/agent/loop/conversationPersistence.ts,git:b98a073e) - 成功的显式验证证据会在后续 Edit、Write、ApplyPatch 或 NotebookEdit 成功时清空;独立验证的 mutation revision 也同步失效,PASS 不能跨源码修改复用 (
packages/cli/src/agent/loop/completionPolicy.ts,packages/cli/src/agent/loop/independentVerification.ts) - 非平凡实现门禁只在主 Agent 修改至少 3 个实现文件、触及高风险路径或执行潜在写 Bash 时触发;子代理、禁止委派、exactly-once Task 契约或不可用 Task 工具会跳过这一门禁 (
packages/cli/src/agent/loop/independentVerification.ts) - 用户明确要求的 test、lint、type-check、build 是另一道完成门禁;它按请求中的具体类别匹配成功 Bash 命令,运行了任意一种检查并不自动满足全部要求 (
packages/cli/src/agent/loop/completionPolicy.ts) - 合法结构化终态只能通过保留的
StructuredOutput工具提交,JSON prose 不算完成;新 steering 或后续 workspace mutation 会清除已接受对象并重置纠正预算 (packages/cli/src/agent/loop/executeLoopGenerator.ts,packages/cli/src/services/StructuredOutputService.ts) StructuredOutput恢复同时校验 schema digest 和对象内容;恢复扫描遇到更新的 user message 会停止,旧 schema 或旧输入下的结果不会被误复用 (packages/cli/src/services/StructuredOutputService.ts)- Stop hook 超时或抛错采用保守的“允许停止”结果,而不是无限阻塞完成;只有明确返回
shouldStop: false才注入继续提示并使 Goal 验证失效 (packages/cli/src/agent/loop/completionPolicy.ts,packages/cli/src/agent/loop/executeLoopGenerator.ts) - Plan 批准后会先持久化 Session permission mode,再把批准内容包进用户消息并重新进入普通 loop;Plan run 的成功结果本身不是任务执行完成 (
packages/cli/src/agent/Agent.ts) - 默认 Agent 已取消固定 100 回合上限,
-1表示无限;防止无界循环依靠输出重复、动作停滞、预算与完成门禁,而不是隐含 turn ceiling (packages/cli/src/agent/loop/executeLoopGenerator.ts,git:85643629)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 75 lines · 145 tokens per session scan A 2322d39b92d3
knowledge-agent-execution-and-orchestration-decision-loop-and-completion is a skill published in the GitHub repository echoVic/blade-code (178 stars, last pushed 2d ago), licensed MIT. It adds 145 tokens to every session and 2,679 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
smiles-validation
Strict SMILES validation, structural comparison, and modification verification. Catches invalid LLM-generated molecules.
tricorder-cli
Full CLI reference for the tricorder daemon (build diagnostics, test results, source lookup, eval comments, logs). This is the fallback invoked by the tricorder skill when the tricorder-mcp MCP tools aren't available or aren't working — invoke tricorder first; it decides whether this is needed.
tricorder-mcp
Check GHCi build status, diagnostics, and test results for this Haskell project via the tricorder MCP server. Use when asked to check the build, see compiler errors/warnings, or run tricorder.
tricorder
Check GHCi build status, compiler errors/warnings, or test results for this Haskell project. Use when asked to check the build, see errors/warnings, or run tricorder.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
systematic-debugging
4-phase root cause debugging: understand bugs before fixing.