reliable-mutations
它能做什么
这项技能说明智能体应如何进行数据库更改,使其真正生效:使用一次批量调用,然后验证结果。适合开发者,以及期望大量条目被保存的人。
适用场景
- ✓当智能体必须一次保存或更新大量条目的时候。
- ✓当一项长时间任务修改应用数据,并且必须在所有内容都保存后才能完成的时候。
- ✓当智能体报告成功,而你需要证据证明数据确实已存储的时候。
技能链接
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/reliable-mutations/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请一次性更新所有这些条目,然后确认它们确实已被保存。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体不会进行多次可能中途停止的小型保存,而是在一次操作中发送整组数据,然后检查已存储的数据,并以数量或 ID 作为证据进行汇报。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Reliable Mutations
Rule
Make a change in one atomic call when the action supports it, then verify the persisted end state and report concrete proof (counts/ids). Never drive a multi-step change by looping many small writes, and never report success from a tool ✓ alone.
Why
Hosted foreground agent runs have a short soft budget so they can hand off cleanly under synchronous serverless walls. Durable background runs get a much longer budget, but they still should not rely on loops of many small writes: continuations can retry the same intent and leave partial state if each item is committed separately. One atomic call commits or fails as a unit; verification turns a hopeful ✓ into a fact.
How
- Prefer a single atomic call. If an action accepts the whole set (add many, set all, bulk update), pass the full batch in one call so it commits atomically. Check the action surface for a batch/plural form before reaching for a loop.
- Do not loop many small writes under any run budget. A sequence of N
per-item writes can still leave partial or no state when a foreground run
hands off, a background run continues, or an upstream provider fails. If no
batch action exists, that is a gap in the action layer — add or extend an
action that accepts the batch (see the
actionsskill) rather than papering over it with a loop. - Verify the end state after writing. Re-read the data (a list/read action,
a count query) and confirm the result matches intent — the right number of
rows, the expected ids/fields. Do this before you tell the user it worked,
and include the relevant verification expectation in the app's
AGENTS.md. - Report proof-of-done, not vibes. State concrete evidence: "saved 12 of 12 panels (ids …)" or "updated 5 rows". Do not infer success from the presence of a tool ✓ on an individual call.
- On a time-budget cutoff, fail loud. If the turn is cut before the change is fully committed and verified, say so explicitly and report what did persist (M of N) and what remains. Never round a partial or unverified write up to "done".
Don't
- Don't loop
for each item: write(item)for a large set in a single hosted turn. - Don't claim completion because every tool call returned ✓ — a ✓ on an aborted chunk does not mean the row was committed.
- Don't silently shrink the scope ("I added a few of them") and present it as the finished task.
- Don't try to "fix" this by asking for a longer run timeout — the budget is correct; restructure the write instead.
Related
actions— define or extend a batch/atomic action when only per-item writes exist.storing-data— where app data lives and how reads/writes are scoped.performance— avoid query waterfalls when verifying end state.- Design doc:
packages/core/docs/design/durable-agent-runs.md— the real ceiling fix (checkpointed and durable runs); this skill is the agent-facing mitigation that reduces how often the ceiling is hit.
常见问题
如果应用没有批量操作怎么办?
技能说明应添加一个批量操作,而不是运行一连串的小型写入循环。
为什么不直接相信成功的提示?
即使部分写入失败,也可能出现成功提示,因此技能要求检查已存储的数据。
这也适用于后台任务吗?
适用。后台运行可能会重试,因此仍然优先使用全部成功或全部失败的单次调用。
详情
作者的原始描述
How the agent must perform writes so they actually persist under the hosted foreground run budget and long-running background handoffs. Use whenever you create, update, delete, or batch-write app data — especially "do this for many items" loops, or any task where the user expects N things to end up saved.
repo: BuilderIO/agent-native
热度
- GitHub 星标
- 7.6k
- 排名
- #13177
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …