审查生成的边界选择器

来自 智能体使用边界
Node 24 进阶 9分钟 找出 4处问题

在这段生成的任务路由代码控制智能体访问之前审查它。

意图未决、数据敏感或效果不可逆时选择人工主导;规则完全稳定时选择简单自动化;其他情况只有具备测试且最大步骤数为 1 至 20 时才允许智能体。

JavaScript
function chooseRunner(task) {
  let score = 0;
  if (task.intentSettled) score += 2;
  if (task.hasTests) score += 2;
  if (task.sensitive) score -= 1;
  if (task.irreversible) score -= 1;

  if (score >= 2) {
    return { method: "agent", maxSteps: task.maxSteps || 100 };
  }

  if (task.stableRule) {
    return { method: "agent", maxSteps: 100 };
  }

  return { method: "human-led", maxSteps: 0 };
}

const request = {
  intentSettled: true,
  hasTests: true,
  sensitive: true,
  irreversible: false,
  maxSteps: -5,
};

生成代码仅作示例,不代表任何特定模型

在试验场中打开
报告错误