Agent · 进阶
任务完成检查
根据 tool 结果和最终状态,判断 Agent 是否真的完成了任务。
NoulChoice
适合什么时候使用
- Agent 质量检查
- stop hook
- 工作流检查
示例 state
{
"requested_task": "Update the account plan to Pro.",
"assistant_claim": "Done — the account is now on Pro.",
"tool_events": [
{
"tool": "update_plan",
"status": "error",
"detail": "permission denied"
}
],
"final_observed_state": {
"plan": "Starter"
}
}决策问题
Noultask_complete
tool 结果和最终状态是否证明任务确实完成?Agent 自己说“已完成”不能单独作为证据。
Choicereview_route
选择下一步审核路由。
close— 证据证明任务已完成retry— 任务未完成,但可以安全重试debug— 执行失败,或证据与完成声明矛盾human_review— 证据或授权边界需要人工处理
预期输出
任务完成的概率,以及下一步应该 close、retry、debug 还是人工审核。
TypeScript 示例
import { choice, noul, TypeSafeClient } from "@typesafe-ai/sdk";
const client = new TypeSafeClient();
const result = await client.systemOne({
state: {
requested_task: "Update the account plan to Pro.",
assistant_claim: "Done — the account is now on Pro.",
tool_events: [
{ tool: "update_plan", status: "error", detail: "permission denied" },
],
final_observed_state: { plan: "Starter" },
},
questions: {
task_complete: noul(
"Does tool evidence and the final state establish actual completion? The assistant's claim alone is not evidence."
),
review_route: choice("Choose the next review route.", {
close: "Evidence establishes completion",
retry: "Incomplete but safe to retry",
debug: "Execution failed or contradicts completion",
human_review: "Needs human review",
}),
},
});为什么这样设计
- state 里把 Agent 的声明和独立证据分开。
- 判断时优先看 tool 结果和最终状态,而不是 Agent 自己的完成声明。
- 下一步只有几个固定选项,业务代码可以直接处理。
注意事项
- 校验器只能判断你实际提供的证据。
- 对高风险操作,还要配合明确的完成条件(post-condition)检查。
来源与参考
这个模板和来源链接最近核验:2026-09-21。
继续浏览
先在Playground中运行这个模式,浏览全部模板,了解官方 SDK 用法,或使用成本计算器估算实际使用成本。