Review a generated boundary selector

from Agent use boundaries
Node 24 intermediate 9 min 4 issues to find

Review this generated task-routing code before it controls agent access.

Select human-led work whenever intent is unresolved, data is sensitive, or an effect is irreversible; select simple automation for a fully stable rule; otherwise permit an agent only with tests and a positive maximum of 20 steps.

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,
};

generated code is illustrative, not from any one model

Open in playground
Report an error