Goal-based and utility-based agents: choosing by what you want, and how much

A goal-based agent picks actions that reach a target. A utility-based agent scores the options by cost, time, and risk. Use them when several routes work and the trade-offs matter.

Goal-based and utility-based agents in 60 seconds

  • What: a goal-based agent chooses actions that reach a stated target. A utility-based agent also scores each option and picks the highest.
  • The difference: a goal gives a yes or no. Utility gives a number, so two ways of reaching the goal can be compared.
  • Best for: decisions with trade-offs, such as refunds, routing, scheduling, and purchasing, where cost, time, and risk compete.
  • Weak spots: a badly weighted score gives confident wrong choices, and models are poor at inventing consistent numbers.
  • Origin: Russell and Norvig's textbook sets out the goal-based and utility-based agent kinds as steps beyond simple reflex agents.

Where this type fits

In the Types of AI agents hub, this page belongs to the second family: what an agent is built around. Instead of describing how an agent loops, it describes what the agent aims at. A goal-based or utility-based design can sit on top of a planning agent, a tool-using agent, or a simple routing step. It answers the question 'what counts as a good choice here?'

The problem it solves

Without an explicit goal, an agent drifts. Ask a model to 'help with this customer' and it may offer a refund, an apology, or a long explanation, depending on how the prompt landed. Each reply may sound reasonable, yet two similar cases get different outcomes, and nobody can say why.

A stated goal fixes the target. 'Resolve the billing dispute within policy' tells the agent what success means and lets you check whether it got there. But a goal alone has a second problem. Many actions reach the same goal at very different cost. A refund, a credit, and a replacement may all end the dispute. If the agent picks at random among them, the business loses money or the customer loses patience.

Utility solves that. You describe what matters (cost, time, risk, customer effort), give each a weight, and have the agent score every option. The choice becomes explainable: option B won because it scored 0.74 against 0.51 and 0.30. When the business changes its mind, for example risk now matters more, you change a weight instead of rewriting a prompt.

How it works

  • State the situation and the goal: write down the facts of the case and what success means in checkable terms, such as 'dispute closed, within refund policy'.
  • Generate options: the model or a rule set lists the candidate actions. Keep the list short, usually three to six, and always include a safe option such as 'escalate to a person'.
  • Filter by hard rules: remove any option that breaks a constraint, such as a refund above the agent's limit. Rules are yes or no. They are not weighed.
  • Score the rest: rate each remaining option on each criterion (cost, time, risk), then combine the ratings using agreed weights into one number.
  • Pick and act: choose the highest score. If the top two are very close, or the best score is below a floor, escalate instead.
  • Log the reasoning: store the options, the scores, and the choice so the decision can be reviewed.
One situation, three options, one scoring step, and a single chosen action.

The diagram shows a supplier payment. The goal is 'settle this invoice correctly'. Three options exist: pay now and accept a 2 percent fee, pay in 3 days at no fee, or send it to a person. All three feed one scoring box. That single shared step is the key idea: every option is judged by the same yardstick, so they can be compared.

The last box is deliberately plain. It picks the top score and acts. Any cleverness belongs earlier, in generating good options and in setting sensible weights. If you find the final step needs lots of special cases, the scoring is probably wrong.

A worked example

Acme Corp has an invoice for 1,000 units of currency, due in 5 days. Its payment agent has this goal: pay correctly and on time, within the agent's approval limit of 5,000.

Options. A: pay now through an express channel with a 2 percent fee (20 units). B: pay in 3 days through the standard channel at no fee. C: escalate to a person.

Hard rules. The amount is under the limit, and the supplier is on the approved list. All three options pass.

Scoring. Each criterion is rated from 0 (bad) to 1 (good). Weights: cost 0.4, time risk 0.3, error risk 0.3.

  • A: cost 0.5 (fee), time risk 1.0 (paid at once), error risk 0.8. Score = 0.2 + 0.3 + 0.24 = 0.74.
  • B: cost 1.0 (no fee), time risk 0.8 (2 days of slack), error risk 0.8. Score = 0.4 + 0.24 + 0.24 = 0.88.
  • C: cost 0.6 (staff time), time risk 0.4 (may be slow), error risk 1.0 (a person checks). Score = 0.24 + 0.12 + 0.30 = 0.66.

Decision. B wins at 0.88, and it beats the next option by more than the 0.10 margin, so the agent schedules payment in 3 days. If the due date had been tomorrow, B's time risk would have dropped to 0.3, its score to 0.67, and A would have won. The same agent, with the same weights, gives a different answer because the facts changed.

A logged decision record (illustrative) (json)
{
  "case": "inv-8841",
  "goal": "pay_correctly_and_on_time",
  "weights": { "cost": 0.4, "time_risk": 0.3, "error_risk": 0.3 },
  "options": [
    { "id": "A", "action": "pay_now_express", "score": 0.74 },
    { "id": "B", "action": "pay_in_3_days", "score": 0.88 },
    { "id": "C", "action": "escalate", "score": 0.66 }
  ],
  "chosen": "B",
  "margin": 0.14
}

Building it

The code keeps the model's job small: propose options and rate them. Your own code applies the hard rules and does the arithmetic, since models are unreliable at consistent maths and at keeping rules fixed.

Goal, hard rules, weighted scoring, and escalation (illustrative) (python)
# Placeholders: llm and log are stand-ins, not real libraries.

WEIGHTS = {"cost": 0.4, "time_risk": 0.3, "error_risk": 0.3}  # sum to 1.0
MIN_SCORE = 0.5     # below this, the agent should not act alone
MIN_MARGIN = 0.10   # a near tie is a sign to ask a person
MAX_OPTIONS = 6     # bound the model's list so scoring stays cheap

def violates_rules(option, case):
    # Hard rules are code, not prompt text. They are never traded off.
    if option["amount"] > case["approval_limit"]:
        return True
    if not case["supplier_approved"]:
        return True
    return False

def rate(option, case):
    """Ask the model for 0..1 ratings per criterion. Placeholder call."""
    ratings = llm.generate_json(
        prompt=f"Rate this option 0 to 1 on {list(WEIGHTS)}: {option} for {case}",
        timeout_s=20,
    )
    # Clamp so a stray value cannot dominate the sum.
    return {k: min(max(float(ratings[k]), 0.0), 1.0) for k in WEIGHTS}

def score(ratings):
    return sum(WEIGHTS[k] * ratings[k] for k in WEIGHTS)

def decide(case):
    options = llm.generate_json(f"List options for: {case}", timeout_s=20)
    options = options[:MAX_OPTIONS]
    allowed = [o for o in options if not violates_rules(o, case)]
    if not allowed:
        return {"action": "escalate", "why": "no option passes the rules"}

    scored = sorted(
        ((score(rate(o, case)), o) for o in allowed),
        key=lambda pair: pair[0],
        reverse=True,
    )
    best_score, best = scored[0]
    runner_up = scored[1][0] if len(scored) > 1 else 0.0

    log.write({"case": case["id"], "scored": [(s, o["id"]) for s, o in scored]})

    if best_score < MIN_SCORE or (best_score - runner_up) < MIN_MARGIN:
        return {"action": "escalate", "why": "low score or near tie"}
    return {"action": best["action"], "score": best_score}

Design decisions

  • Hard rules versus weights: put anything that must never happen, such as limits and compliance, in code as a filter. Use weights only for real trade-offs. Mixing the two lets a high score buy a rule break.
  • Who sets the weights: the business owner, not the engineer. Store them in versioned configuration so a change is visible and reversible.
  • Where scores come from: use measured values (fees, days, prices) wherever they exist. Use model ratings only for things that cannot be measured, and ask for coarse bands such as low, medium, high.
  • Option generation: keep the list short and always include a safe fallback. A missing good option cannot be fixed by better scoring.
  • Escalation rule: escalate when the best score is low or the top two are close. A recommended default is a floor of 0.5 and a margin of 0.1, tuned on past cases.
  • Explainability and audit: log options, ratings, weights, and version for every decision. This is cheap and makes disputes easy to settle.
  • Failure handling: if the model's output is malformed or times out, escalate. Do not guess a score.

Measuring it

  • Agreement with experts: collect a set of past cases where a person chose the best option, and compute how often the agent's top choice matches. Report it by case type.
  • Rank quality: check where the expert's choice falls in the agent's ranking. Landing second often means the weights are slightly off.
  • Rating consistency: score the same case several times and measure the spread of the ratings. A wide spread means the rating prompt is unstable.
  • Escalation rate and precision: the share of cases escalated, and of those, how many a person agreed needed escalation. Too low is risky, too high wastes staff time.
  • Realised cost: compare the cost of chosen actions against the cheapest valid option in hindsight. This shows whether the utility is steering well.
Agreement with expert choices (illustrative) (python)
def agreement(cases):
    # each case has the expert's choice and the agent's ranked ids
    top1 = sum(1 for c in cases if c["ranked"][0] == c["expert"])
    top2 = sum(1 for c in cases if c["expert"] in c["ranked"][:2])
    n = max(len(cases), 1)
    return {"top1": top1 / n, "top2": top2 / n}

When to use it, and when not to

SituationUse this type?Why
Several valid actions with different cost or riskYesScoring makes the choice consistent and explainable.
There is one right answer, such as a lookupNoA goal is enough, and scoring adds noise.
Business owners want to tune priorities without code changesYesWeights live in configuration and can change quickly.
Decisions must be defended to auditors or customersYesLogged scores and rules give a clear reason for each choice.
The criteria cannot be named or agreedNot yetSettle what matters first. Weights built on guesses give false confidence.
Options and facts change constantlyMaybeUse measured inputs and refresh them, or the scores go stale.
A wrong choice is severe and irreversibleYes, with a personUse the score to recommend, and have a person approve.

Trade-offs

DimensionEffectWhat to do about it
QualityMore consistent choices and clearer reasons.Check against expert decisions and retune weights from real cases.
LatencyExtra model calls for options and ratings.Rate options in parallel, and use fixed rules where the answer is obvious.
CostSeveral calls per decision instead of one.Cap the option count and skip scoring when only one option passes the rules.
ComplexityNeeds weights, rules, logs, and an owner for each.Start with two or three criteria and add more only if they change choices.
Failure modesFalse precision, gamed criteria, and unstable ratings.Use coarse bands, test consistency, and escalate on near ties.

A planning agent decides the order of steps toward a goal. A utility-based agent decides which goal-meeting action is best. They fit together: plan first, then score the alternatives at the points where choices branch. A tool-using agent can supply the facts that feed the scores, such as live fees or stock levels.

When a score is low or a margin is thin, hand over to a person with a human checkpoint. That keeps automated choice for clear cases and human judgement for the hard ones.

What this means for your role

Common mistakes

Further reading

  • Types of AI agents: the hub page for all agent types.
  • Russell and Norvig, Artificial Intelligence: A Modern Approach: the classic taxonomy of simple reflex, model-based, goal-based, utility-based, and learning agents.
  • Planning agent: how an agent breaks a goal into steps.
  • Guardrails and safety: how to enforce hard limits around an agent.

A goal tells an agent where to go. Utility tells it which road to take. Keep the rules firm, the weights owned, and the escape hatch close.

Search topics

↑↓ to move · Enter to open · Esc to close