Daily Tech Briefing
AI 科技速览
每天 5 分钟内学习 AI。获取最新的人工智能新闻,理解其重要性,并学习如何将其应用于您的工作。
Dev.to AI · 2026/7/22 10:20:10

Teaching my AI agent when to knock — and when to shut up
AI 中文解读
AI智能体疯狂“打扰”人类的问题终于有了简单解法。一位开发者发现,用免费通知工具ntfy.sh就能让AI只在关键时刻“敲门”——任务完成或遇到无法自主决策的障碍时才通知,其他时候保持安静,再也不会半夜2点发来无意义的进度报告。技术实现只占20%的工作量,真正难的是制定三条“呼叫纪律”和绕过七种实战坑:比如中文字符乱码、通知超时导致报告“假完成”等。这些经验已被整理成开源项目knock-knock,一个纯文本技能文件,配合Claude Code等LLM工具即可使用。对于普通用户和AI开发者而言,这意味着不再需要“保姆式”盯着终端,AI真正学会了“不该说的闭嘴,该说的时候说人话”。这种“何时该打断人类”的交互逻辑,仍是行业尚未充分探索的领域。
<p>My agent used to finish long tasks at 2 AM and just... sit there. I'd either babysit the terminal or come back hours later to find it had been waiting for one yes/no decision the whole time.</p>
<p>The fix took one HTTP request: <a href="https://ntfy.sh" rel="noopener noreferrer">ntfy.sh</a> — free, no signup. My phone gets the app and subscribes to a private topic; the agent posts to that topic when something actually needs me.</p>
<p>The technical part was the easy 20%. Two things turned out to matter more:</p>
<h2>
1. Calling discipline
</h2>
<p>An agent with a notification channel and no rules becomes a spam machine. Ours follows three rules: ping when the task is wrapped up and the owner is away; ping when hard-blocked on something only the owner can decide; stay quiet for everything else — no progress updates, no repeated nagging about the same thing.</p>
<h2>
2. The pitfalls (seven of them, all hit in production)
</h2>
<p>If your notifications contain CJK text, passing it straight through the command line turns it into question marks. Nastier ones: hook timeouts killing the request mid-flight (looks exactly like an encoding bug, isn't), notification length limits truncating tables into garbage, and "turn ended" firing when the task wasn't actually done — so the agent sends a victory report while the job is still half-baked.</p>
<p>All seven are written up with fixes in the skill file, so your agent can read it and skip the bruises: <a href="https://github.com/LucioLiu/knock-knock" rel="noopener noreferrer">github.com/LucioLiu/knock-knock</a></p>
<p>It's a plain markdown skill — works with Claude Code or any LLM tool that reads files. Uninstall = delete one folder.</p>
<p>Disclosure: my own repo. Curious how others handle the "when should the agent interrupt me" problem — that part still feels underexplored.</p>
<p><a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkcuairhgmxst9fquq10w.png" class="article-body-image-wrapper"><img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkcuairhgmxst9fquq10w.png" alt=" " width="800" height="449"></a></p>
分享
阅读原文 ↗