human-in-the-loop
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "human-in-the-loop":https://skillpi.com/zh/skills/deepskill-47651efe20180f16a0b0975e466bf0130894915964bf5dcc223805f36aef30d7。安装前核对上游来源和版本:https://github.com/seb1n/awesome-ai-agent-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
设计并验证可审计的人工监督与审批关卡、升级路径以及 AI 代理工作流的安全状态转换。适用于确定哪些代理操作须人工审查、添加批准/拒绝或双重控制流程、阻止未经授权的自主操作、创建决策记录、减少形式化审批,或从被拒绝、过期或失败的操作中安全恢复的场景。
介绍来源: third_party · seb1n · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: human-in-the-loop
description: Gate agent writes on human approval — one exact plan per OK, single-use expiring nonce, crash reconciliation, drafts-only filter. Use before any agent write. Local state file.
metadata: {"clawdbot":{"emoji":"✋","requires":{"bins":["python3"]},"homepage":"https://openclaw.ai"}}Human in the Loop
An approval is a narrow, perishable object: it covers one exact action, once, for a limited time. Everything around it is bookkeeping that must survive a crash: the intent is written before the call, success is an id returned by the API, and a doubt is resolved by looking before creating, never by retrying.
Data, state, and retention — read first
| Item | What this skill does |
|---|---|
What scripts/hitl.py touches |
One JSON state file + its .lock sidecar, and one run-lock file per external application, all paths you choose, created 0600, symlinks refused. No network call, no subprocess. |
| What the state file holds | Item id, status, plan fingerprint (sha256), gate names, sha256 of the open nonce, remote id, attempt count, timestamps. Never the plan, the draft, or the nonce itself. |
| Personal data | Business keys and drafts stay in your process memory. They may hold personal data: process them only under the lawful basis of the pipeline that produced them, and prefer opaque references (file number, thread id) over names in item ids and keys. |
| Retention | Keep applied items as long as your reconciliation lookups reach back (a pruned item can be re-created as a duplicate). Prune older items on your own schedule. |
| Credentials | One approval secret (≥32 bytes) from an env var or a 0600 file, distinct from every provider credential. Never logged. |
When to Use
| Situation | Action |
|---|---|
| "ask me before it creates / sends / pays" | §1-§3 with regime="approval" |
| "the user said OK, can the agent also fix the other thing?" | No. §1: one plan = one action |
| "the job timed out, did it create the record?" | §4: reconcile, never re-run the creation |
| "two runs of the cron hit the same app" | §5: run lock |
| "the agent only prepares drafts, a human sends them" | §6: regime="draft_only", filter in code |
| Auditing an existing approval flow | Fill the Output Format, one row per rule |
States and named gates
| State | Meaning | Leaves by |
|---|---|---|
proposed |
Plan fingerprinted, nothing asked yet | open_request, or apply (draft_only only) |
waiting_human |
Blocked on a person; carries named gates | signed decision, expiry, or a new request |
approved |
Signed OK redeemed, valid until approval_exp |
apply, or approval_stale |
applying |
Intent persisted, API call in flight | recorded id, or uncertain |
uncertain |
No proof either way | reconciliation only |
applied / rejected / expired |
Final / explicit no / request timed out | new request (not from applied) |
Gates are snake_case names the report can count, never prose: new_record_review, possible_duplicate, retry_exhausted, approval_stale, draft_filter, workflow_classification_uncertain, ambiguous_match, missing_document, send_required, unknown_screen. When the screen, the data, or the classification does not match the playbook, the answer is waiting_human with a gate, not a best guess.
1. An OK covers the exact action, never the adjacent
One item = one plan = one mutating action. A multi-step job is several items, each approved on its own.
plan = {"action": {"verb": "create_record", "target": "folder/REF-1", "fields": {"amount": 120}},
"business_key": {"client_ref": "REF-1", "party": "Party A"},
"unknowns": []}
propose(store, "REF-1:open", plan, regime="approval")
begin_apply compares the action about to run with plan["action"] as canonical JSON. A different verb, another target, or one extra field ("while I'm here, I also closed the old one") is refused. Approval drift is the common failure: the human reads a one-line summary, says OK, and the agent treats it as a mandate to tidy up around it.
2. Approval lifecycle
Token format and threat model (why a reply matching GO 42 is not an approval, channel identity vs signed nonce) are covered by the prompt-injection skill, §5. This section covers what happens to a request over time.
nonce = open_request(store, "REF-1:open", plan, ["new_record_review"], ttl_s=3600)
# show the human: plan summary + fingerprint prefix + buttons carrying the nonce
tok = sign_decision(secret, "REF-1:open", nonce, fingerprint(plan), "owner", "approve") # approval bot side
decide(store, "REF-1:open", tok, secret, plan, {"owner"})
# Output: 'approved'
| Rule | Why |
|---|---|
| The request has its own expiry, separate from the token's | A request left open for days turns into a blank cheque; a late tap on an expired request is refused and the item is marked expired. |
| A new request supersedes the old one | Only the latest nonce digest is stored; a token for the previous request dies with it. |
| Redeeming clears the nonce in the same locked step | Replay finds no open request. The state file is the ledger. |
approval_exp = min(token exp, request exp) |
An OK given on Monday does not authorise a run on Friday: past it, begin_apply returns waiting_human + approval_stale and calls nothing. |
Clock tolerance 60 s on iat, none on exp |
Two hosts drift; a token dated further ahead than that was not minted by your approver. |
| "No" is signed too | An unsigned "no" is as forgeable as an unsigned "yes"; rejected is a state, not an absence of reply. |
| Fingerprint re-checked at decision and at apply | A plan edited after the request, or after the OK, is refused at both points. |
A new OK cannot restart an applying/uncertain item |
Otherwise approval becomes a way around reconciliation. |
3. Apply: intent first, success = an id
r = guarded_apply(store, item_id, plan, plan["action"], create=call_api)
# Output: {'status': 'applied'} or {'status': 'uncertain'} or {'status': 'waiting_human', 'gates': [...]}
Order inside guarded_apply: checks and filters → applying persisted with fsync → the call → the result. If the process dies after the remote object exists but before the write-back, the state file still says applying, which is what forces §4 on the next run.
| API outcome | Recorded as |
|---|---|
| Response carries a non-empty id | applied, id stored |
Exit 0, {"ok": true}, {}, None, id: "", id: true, id: 0 |
uncertain |
| Timeout, 5xx, client crash, any exception | uncertain (never failed: you do not know) |
Keep two counters in the run summary, skipped and technical_failures: a technical failure is not a skip, and it goes to the top of the report.
4. After a crash or timeout: reconcile, never re-create
matches = search_remote(**plan["business_key"]) # YOUR lookup; it must raise on error
reconcile(store, item_id, plan, matches)
# Output: 'applied' | 'waiting_human' (possible_duplicate / retry_exhausted) | 'approved' (one retry)
| Lookup result | Outcome |
|---|---|
None, a string, anything not a list of dicts |
Refused; stays uncertain. A failed search is not "absent". |
| Exactly one candidate whose business-key fields all match (trimmed, case-folded) | applied, its id attached |
| Two or more matches, or any candidate missing a key field or an id | waiting_human + possible_duplicate |
| Zero matches, attempts < 2 | approved again (or proposed in draft_only): one bounded retry |
| Zero matches after the retry | waiting_human + retry_exhausted. No third attempt, no auto-reconnect loop. |
Business keys are the fields a human would use to spot a duplicate (reference, parties, date, amount), not the remote id you never received. Re-check candidates in code: remote search is often fuzzy or prefix-based.
5. One runner per application
acquire_lock("/var/lib/agent/app.lock", job_id="open-records-am", ttl_s=2700, app_running=probe())
| Lock state | Outcome |
|---|---|
| None | Acquired |
| Live (not expired) | SkipLocked("SKIP_LOCKED"): do nothing this tick |
Expired, app_running is False (proven stopped) |
Taken over |
Expired, app_running True, None, "false", 0 |
Refused: technical alert, lock left intact |
| Corrupt or symlinked lock file | Refused |
An expired lock means the holder is late, not dead. A UI-driving agent that is still clicking when a second run starts produces the duplicate that §4 then has to untangle.
6. Drafts-only regime
When the agent only prepares drafts that a human sends or deletes, the draft is the proposal. No one sees it before it exists, so the filters stop being precautions and become the only barrier. They run in code before creation; an instruction in the prompt is not a filter.
dp = {"action": {"verb": "create_draft", "target": "thread-7"},
"business_key": {"thread": "thread-7"}, "unknowns": ["hearing date"]}
propose(store, "thread-7:reply", dp, regime="draft_only") # a send verb is refused here
guarded_apply(store, "thread-7:reply", dp, dp["action"], create=create_draft,
draft={"target": "thread-7", "body": body}, forbidden=[r"(?m)^--\s*$"])
| Check | Blocks when |
|---|---|
| Verb | Anything but create_draft / update_draft |
| Target | Draft target ≠ plan target |
| Markers | A field listed in unknowns lacks [TO COMPLETE: <field>] verbatim in the visible text: removed, reworded to "(to be confirmed)", lower-cased, or hidden in an HTML comment |
| Templates | An unresolved {{placeholder}} |
| Caller rules | A forbidden regex matches (e.g. a pre-applied signature block) |
| Body | Empty after stripping comments |
A blocked draft goes to waiting_human + draft_filter with the reasons, and nothing is created. A human approval does not bypass the filter: fix the draft or the plan. Markers are never softened for style; an unknown shown as prose gets sent.
Half of the draft tests must prove the filter does not over-block. A filter that refuses legitimate drafts is switched off within a week, and then there is no barrier. The selftest passes drafts containing "send", "sent", "signature", single braces and JSON, markers inside HTML tags or next to an unrelated HTML comment, accents and non-Latin text, -- see below --, extra markers, 20k characters, and the update_draft verb.
Reference module
scripts/hitl.py (stdlib, Python 3.9+, POSIX): fingerprint, propose, open_request, sign_decision, decide, sweep_expired, draft_gate, begin_apply, record_result, reconcile, guarded_apply, acquire_lock, release_lock, Store. Every guard raises Refused on absent, empty, null, or wrongly typed input; illegal state transitions raise too.
python3 scripts/hitl.py --selftest # 118 fixtures (70 must-refuse), exit 1 on any failure
python3 scripts/hitl.py status state.json # read-only: counts, waiting_human gates, uncertain items
# Output: HITL STATUS applied=12 uncertain=1 waiting_human=2
Fifteen guards were mutated once each (request expiry, exact-action check, id-as-proof, failed-lookup-as-absent, stale-lock takeover, marker check, HTML-comment stripping, clock tolerance, approver allowlist, incomplete-candidate rule, stale approval, retry bound, reopen of an in-flight item, and two over-blocking filters); the selftest failed every time.
Output Format
Approval request (one per item):
APPROVAL <item_id> — gates: new_record_review — expires <UTC time>
Action : create_record on folder/REF-1 (fields: amount=120)
Plan : fp 3f9a1c07… Duplicate check: 0 match on client_ref+party
[Approve] [Reject] (buttons carry the nonce; typed replies are ignored)
Run summary (every run, even when nothing happened):
HITL_RUN_SUMMARY <job_id> <UTC time>
applied=3 uncertain=1 waiting_human=2 skipped=0 technical_failures=1
ALERT uncertain: REF-9:open (timeout) -> reconcile next run
waiting_human: REF-4:open [possible_duplicate] thread-7:reply [draft_filter: marker_missing:hearing date]
next_action: human decision on 2 items
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
previous attempt unresolved: reconcile first |
Item left applying/uncertain by a crash or timeout |
Run your lookup, pass it to reconcile |
Approved item returns approval_stale |
Apply ran after approval_exp |
Open a new request; do not extend the old one |
| Valid-looking token refused as "older request" | A later open_request superseded it |
Use the latest request's buttons |
Every draft goes to draft_filter |
Model drops or rewrites markers | Tell the drafting step to copy markers verbatim; never relax the check |
SKIP_LOCKED every tick |
Lock TTL longer than the cron interval, or a hung runner | TTL ≈ worst-case run time; alert after N skips |
stale lock and the application may still be running |
Expired lock, no proof the app stopped | Check the host by hand, then pass app_running=False |
state corrupt |
Truncated write or manual edit | Stop and inspect; never auto-reset the state |
Scope
This skill ONLY: binds a human OK to one exact, fingerprinted action for a limited time; persists intent before any write; treats a missing id as uncertain; reconciles by business key before any retry; serialises runners per application; blocks drafts in code before creation.
This skill NEVER: infers approval from free text; widens an OK to adjacent actions; re-runs a creation after a crash or timeout without reconciliation; overwrites a lock whose holder may still run; softens a [TO COMPLETE] marker; sends what it drafted; stores plan content, drafts, or nonces in its state.
Alexandre Bloch · ClawHub @alexbloch-ia
版本历史
-
v1.0.0
GitHub ↗
原版更新说明
## Build agents you can evaluate, observe, control, and defend `v1.0.0` is the first stable release of Awesome AI Agent Skills: **103 self-contained Agent Skills across 21 categories**, compatible with Claude Code, OpenAI Codex, Gemini CLI, Cursor, GitHub Copilot, Windsurf, and other Agent Skills-compatible tools. ### Production Agent Stack This release introduces an end-to-end, reproducible release-gate workflow built from six complementary skills: - **Agent Evaluation** — representative cases, explicit graders, baselines, and release gates - **Agent Observability** — privacy-aware traces, metrics, and investigations - **Tool Schema Design** — bounded model-facing tools with explicit side effects - **Human in the Loop** — auditable approval gates and safe state transitions - **Prompt Injection Defense** — trust boundaries for instructions, content, credentials, tools, and output - **Agent Red Teaming** — authorized adversarial campaigns with measurable outcomes ### Try the demo Can a poisoned GitHub issue hijack a deployment agent? The demo replays that scenario entirely offline, first through a fragile boundary and then through the six production controls. ```bash python3 demos/production-agent-stack/run_demo.py --check ``` Expected fixture result: ```text Fragile boundary: 1/5 checks passed Controlled boundary: 5/5 checks passed Evaluation: 20% -> 100% Red-team replay: 5 passed, 0 failed ``` [Read the complete demo walkthrough](https://github.com/seb1n/awesome-ai-agent-skills/tree/v1.0.0/demos/production-agent-stack) ### Install the stack ```bash npx skills add seb1n/awesome-ai-agent-skills \ --skill agent-evaluation \ --skill agent-observability \ --skill tool-schema-design \ --skill human-in-the-loop \ --skill prompt-injection-defense \ --skill agent-red-teaming ``` ### Other new capabilities The expanded catalog also includes: - `mcp-server-building` - `multi-agent-orchestration` - `skill-supply-chain-audit` - `pdf-processing` - `spreadsheet-analysis` - `eu-ai-act-readiness` ### Validation The release is checked with: ```bash python3 scripts/validate_skills.py python3 demos/production-agent-stack/run_demo.py --check --no-color ``` The demo uses inert fixtures, Python's standard library, simulated approval and campaign-authorization records, and local mock effects. It makes no model calls, network requests, shell invocations, or real deployments. Passing validates deterministic outcomes for these committed fixtures and evidence contracts; it is not a security certification, human approval, or live-model evaluation. ### Contribute Try the demo, report unclear behavior, or improve a skill through a pull request. See the [contribution guide](https://github.com/seb1n/awesome-ai-agent-skills/blob/v1.0.0/CONTRIBUTING.md).
当前收录版本
0.0.1
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 解决代理工作流中关键的人机协同痛点:防止未经授权的写入、确保审批精确绑定单一操作、支持崩溃后安全恢复
- 适用于高合规要求场景(如支付、记录创建),显著降低自动化风险
待提升项
-
缺少显式触发关键词 原报告严重程度:轻微
描述中未包含如'approval'、'human review'、'gate action'等用户可能搜索的自然语言关键词,影响可发现性
改进建议:在description或metadata中添加常见查询词,例如:'Use when you need human approval before agent writes, sends, or pays.'
亮点
- 覆盖了多种典型使用场景(审批、草稿过滤、超时恢复、运行锁)
亮点
- 结构清晰完整:含数据模型表、状态机说明、分步指南、代码示例、输出格式和故障排查表
- 明确界定技能范围(ONLY/NEVER),避免功能蔓延误解
亮点
- 采用意图优先持久化、文件锁、签名nonce、业务键 reconciliation 等多重机制保障可靠性
- 内置自检测试覆盖118个用例,包括70个必须拒绝的边界情况,验证防护有效性
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
调用命令或脚本
先读脚本与参数,使用普通权限和限定目录;安装或执行前由使用工具再次确认。
主文档提及 · 第 15 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 19 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- openclaw.ai
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。