criogenai

IBM agent types

Utility-based agent

Scores every option by how good it is, picks the best.

A utility-based agent does not just reach a goal, it asks how well each option serves it. A utility function turns price, time and comfort into one score, and the agent picks the highest.

Move the sliders to change what you care about and run it again: the same flights, a different choice.

Use it when
Trade-offs between several criteria
Many options that all reach the goal
Recommendations, pricing, scheduling
Skip it when
Preferences you cannot express as weights
Only one acceptable option

Run it

Scripted model · no key needed · CriogenAI engine in your browser
Ready
scoresOptionsUtilityChoose maxBook
The runmodel 0 · tools 0
  1. Press Run to watch the pattern work, step by step.
Try it with your own key optional: a real model makes the decisions; the tools stay simulated
  • Your key stays in this tab's memory: not saved, not in cookies or the address bar. Reload or close the tab and it is gone.
  • Your browser calls OpenAI directly. Nothing passes through criogenai.com, and nothing is logged.
  • Each run makes at most 16 short model calls, billed to your account. Tools, data and side effects are simulated.

This run is the TypeScript code below, running on the CriogenAI engine in your browser (WebAssembly). Without a key, a scripted model stands in for MODEL; with your key, your provider answers, called from this tab. The tools return made-up data.

Build it with CriogenAI

Built from primitives: A tool or node that scores options
flights = [
    {"name": "Budget, 1 stop", "price": 180, "hours": 9.5, "stops": 1},
    {"name": "Direct, early", "price": 340, "hours": 5, "stops": 0},
    {"name": "Night, 2 stops", "price": 140, "hours": 14, "stops": 2},
]
weights = {"price": 0.4, "time": 0.3, "stops": 0.3}  # what this traveller cares about

def utility(f: Dict[str, Any]) -> float:
    return weights["price"] * (1 - f["price"] / 500) + weights["time"] * (1 - f["hours"] / 15) + weights["stops"] * (1 - f["stops"] / 2)

@tool(read_only=True)
def best_flight() -> dict:
    """The flight with the highest utility for this traveller."""
    return max(flights, key=utility)

agent = Agent(MODEL, instructions="Book the best flight. Use best_flight; explain the trade-off.", tools=[best_flight])
print((await agent.run("Book Lisbon to Berlin.")).text)
const flights = [
  { name: "Budget, 1 stop", price: 180, hours: 9.5, stops: 1 },
  { name: "Direct, early", price: 340, hours: 5, stops: 0 },
  { name: "Night, 2 stops", price: 140, hours: 14, stops: 2 },
];
const weights = { price: settings.price, time: settings.time, stops: settings.comfort }; // what this traveller cares about
const utility = (f: (typeof flights)[number]) =>
  weights.price * (1 - f.price / 500) + weights.time * (1 - f.hours / 15) + weights.stops * (1 - f.stops / 2);

const bestFlight = tool({
  name: "best_flight",
  description: "The flight with the highest utility for this traveller.",
  input: z.object({}),
  readOnly: true,
  run: () => flights.reduce((a, b) => (utility(b) > utility(a) ? b : a)),
});
const agent = new Agent({ model: MODEL, instructions: "Book the best flight. Use best_flight; explain the trade-off.", tools: [bestFlight] });
const result = await agent.run(task);
console.log(result.text);