What is a utility based agent in AI, with an example?

Updated October 2026 · How we answer

Short answerA utility-based agent chooses actions by scoring each possible outcome and picking the best one. It weighs tradeoffs like cost, speed and safety instead of only checking whether a goal is met.

How it works

A goal-based agent asks whether an action moves it closer to the goal. A utility-based agent asks how good each outcome is, using a score called a utility function. It then picks the action that gives the highest expected score.

This matters when several paths reach the goal but differ in quality. A route planner might prefer a slightly longer trip that is safer or cheaper. The utility function turns those preferences into numbers the agent can compare.

  • Goal-based: is this action closer to the goal?
  • Utility-based: how good is each possible outcome?
  • Utility scores let the agent trade off speed, cost and risk

A simple example

Imagine a delivery robot choosing between two routes. One route is fast but crosses a busy road. The other is slower but safer. The robot gives each route a score based on time, risk and battery use, then picks the highest total.

If the utility function gives too much weight to speed, the robot may take risks. Designers test scores on many cases to make sure the behavior matches what people actually want.

  • Set weights for each factor
  • Test edge cases where tradeoffs clash
  • Review the scores when behavior looks wrong

Common mistakes

  • Confusing utility-based agents with simple goal-based agents that only check whether a goal is reached.
  • Picking a utility function that rewards the wrong outcome, which the agent will then pursue faithfully.
From our shopsCaseMorph: Type an idea, see a custom phone case in seconds, then print a one-of-one.