agents · intermediate

Agent Router

Choose the next allowed agent or tool from a constrained graph without treating the model's choice as authorization.

choicenoul

When to use it

Example state

{
  "request": "Check the current rate-limit settings before proposing a change.",
  "current_node": "start",
  "allowed_next": [
    "research_agent",
    "support_agent",
    "ops_agent"
  ]
}

Decision questions

choicenext_node

Choose only among the allowed next nodes.

  • research_agent — Research external or background information
  • support_agent — Handle user-support requests
  • ops_agent — Inspect or propose operational configuration changes
  • clarify — Not enough information to route safely
noulenough_information

Is there enough information in the request and current graph state to choose a next node safely?

Expected structured output

A next-node choice constrained by the current graph and a probability that routing is sufficiently supported.

TypeScript example

import { choice, noul, TypeSafeClient } from "@typesafe-ai/sdk";

const client = new TypeSafeClient();

const result = await client.systemOne({
  state: {
    request: "Check the current rate-limit settings before proposing a change.",
    current_node: "start",
    allowed_next: ["research_agent", "support_agent", "ops_agent"],
  },
  questions: {
    next_node: choice("Choose only among the allowed next nodes.", {
      research_agent: "Research background information",
      support_agent: "Handle user-support requests",
      ops_agent: "Inspect or propose operational configuration changes",
      clarify: "Not enough information to route safely",
    }),
    enough_information: noul(
      "Is there enough information to choose a next node safely?"
    ),
  },
});

Why this design works

Limits and boundaries

Sources and inspiration

Continue

Browse all templates, learn the official SDK shape, or estimate production volume with the cost calculator.