360 Secure SkillHub
360 安全技能中心

Close the Loop

该 Skill 让智能体在处理邮件后把承诺、跟进与截止日期写成绑定 Message-ID 的 directive,靠定时唤醒重查邮箱,给出已确认、失效、被推翻或无法核实四类结论并纠正错误认知;脚本仅用 Python 标准库,支持 IMAP/SMTP 邮箱与 Windows 经典 Outlook,自动推断的 directive 仅可起草不可发送,唤醒与收件箱监控依赖 OpenClaw 的定时能力。

分类:协作
limfuhai
limfuhai
热度 40.63
最近更新 2026-12-04 09:23:12

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add limfuhai/close-the-loop
兼容性
OpenClaw 专属
联网要求
需要联网
数据出网
必须出网
Metadata
name
close-the-loop
description
Lets your agent run email work without a human checking it. It records every commitment, follow-up and deadline as a directive tied to a real Message-ID, wakes itself to re-check each one against the mailbox, catches its own false beliefs (cancelled meetings, revised figures, replies that already came) and corrects them. Use for follow-ups, promises, deadlines, 'did they reply?', 'take over my inbox' and any email task that must stay true over days.
homepage
https://github.com/limfuhai/Close-The-Loop

Close the Loop

Agents left to themselves drift: their notes come to say they sent, promised or arranged things that never happened, or that have since been cancelled. Better memory cannot fix that, because a memory store records a false belief faithfully. Close the Loop fixes it with three roles you play in turn:

  • The ledger (references/ledger.md) owns what is owed and why. It writes directives: one concrete future action each, resting on exact evidence (a Message-ID, a file path).
  • The auditor (references/auditor.md) owns whether it is still true. It checks directives against the mailbox, never against notes, and appends a verdict: confirmed, stale, contradicted or unverifiable.
  • Wake-ups (references/wakeups.md) own when. You schedule your own checks with OpenClaw's cron, so the loop keeps running without anyone asking.

Read the reference file for a role before you act in it the first time in a session.

First use: connect the mailbox

Close the Loop works from the user's own mailbox. If python scripts/mail.py read reports that no account is set up, ask the user for their email address, then set it up in ~/Boundary/mail_account.json one of two ways:

  • QQ, 163, Gmail and most others (IMAP/SMTP): ask for the mailbox's authorization code (QQ/163: 授权码 from the mailbox settings; Gmail: an app password), never the account password, and write {"address": "...", "auth_code": "..."}. Company mail servers also need "provider": "custom" with imap_host, imap_port, smtp_host and smtp_port.
  • Microsoft accounts (Outlook.com, Hotmail, Microsoft 365) on Windows: Microsoft blocks password logins over IMAP, so the scripts work through classic desktop Outlook instead. Write {"address": "...", "provider": "outlook"} with no authorization code. Classic Outlook must be installed and signed in to that address; Outlook on the web alone will not work.

Then run python scripts/mail.py read again to confirm the login works.

How to run the scripts

All scripts are in scripts/, use only Python's standard library, and print one line of JSON. Arguments go in a JSON file you write first (for example ~/Boundary/tmp/args.json), passed by path: python scripts/ledger.py write_directives ~/Boundary/tmp/args.json. Never paste JSON onto the command line. On Windows use python or py, and openclaw.cmd for the OpenClaw CLI.

When to act

  1. After any email task (you read, drafted, sent or arranged something): act as the ledger, occasion post_task. Record what the work left owed, then schedule each new directive's wake-ups.
  2. When the user gives a standing instruction ("always chase invoices after a week"): act as the ledger, occasion human_instruction.
  3. When a wake-up arrives (a message starting "Close the Loop:"): act as the auditor for the named directives, then as the ledger to apply the verdicts. If a directive is confirmed and due, carry out its action within its authority, then close it or record what is still owed.
  4. When the user asks you to take over their inbox: read recent mail in the inbox and Sent, sort it into threads, record what each thread leaves owed as directives, schedule their wake-ups, and draft what needs drafting. Then keep the loop running through the wake-ups. Set up the inbox watch once (references/wakeups.md).
  5. Before acting on any belief about a past email (that something was sent, agreed, scheduled or replied to): if a directive covers it, audit it first. Never act on a stale belief.
  6. When new mail arrives (a wake-up starting "Close the Loop: new mail has arrived"): pass over newsletters, promotions and automated notices quickly unless they bear on an active directive. For the rest, read the ledger. If a message may change an active directive (a reply came, a meeting moved, a figure was revised), act as the auditor for that directive, then as the ledger to apply the verdict. If a message leaves something newly owed, act as the ledger, occasion post_task. If nothing changed, say nothing.

The authority rule

Directives you infer yourself are reversible-only: you may draft, never send. mail.py send refuses unless its arguments carry "confirm_send": true, and you may set that only when the user has told you to send, or for a human-authored directive (authority full). When in doubt, draft and say so.

Reporting

After an audit or a wake-up, tell the user in a short report they can read at a glance:

Close the Loop · checked 3 directives
✗ D-0004 "Q4 budget is 120k": contradicted. Li revised it to 95k (msg <...>). Summary redrafted with 95k.
✓ D-0003 "Waiting on contract reply from Chen": confirmed, still open, next check Thu 09:00.
? D-0006 "Meeting with Wang on Friday": unverifiable. Check-in email drafted.
github.com/limfuhai/Close-The-Loop

Lead with anything you caught and corrected: that is the point. Keep one line per directive, cite the evidence, and end with the repository link. If nothing changed, stay silent unless the user asked.