The Core Idea: At every step an agent must choose: answer now, call a tool, ask the user, or stop. Good decisions weigh the chance of success, the value of the result and the cost of trying, and they know when to ask for help.
- Beginner: Reasoning Patterns
Reasoning is how the model works out what to do before it acts. Several patterns are common, each trading cost for care:
| Pattern | Idea | Best for | Cost |
|---|---|---|---|
| Direct answer | Answer immediately | Simple, familiar questions | Lowest |
| Step-by-step (chain of thought) | Write out the reasoning before the answer | Math, logic, multi-step questions | More tokens |
| Decomposition | Split the problem into smaller parts | Complex tasks | More calls |
| Reason + act (ReAct) | Alternate thinking and tool use | Tasks that need outside information | Many steps |
| Multiple attempts | Try several times and compare or vote | Hard problems with checkable answers | Several times more |
Tip: Match the pattern to the problem. Using the heaviest pattern for every question wastes time and money.
- Beginner: Choosing Actions
At each step the agent's menu of possible actions is short. Naming them clearly makes the behavior easier to control:
| Action | When it is right |
|---|---|
| Answer now | The agent already has enough reliable information |
| Call a tool | It needs data or must do something |
| Ask the user | The request is ambiguous or a risky choice needs approval |
| Retry or change approach | The last attempt failed |
| Stop | The goal is met, or no safe path remains |
Remember: Ask the user and stop are real actions. An agent that can never ask or stop will guess instead.
- Medium: Decision-Making With Expected Value
A simple way to think about choosing is expected utility: how likely is the action to work, how valuable is success, and what does it cost (time, money, risk)?
In the code, four options for the same question are scored. The database query wins because it is both reliable and cheap, even though asking the user is the most likely to succeed.
Why this matters: Real agents do not compute numbers like these, but the model is implicitly weighing the same factors. You can shape its choices by changing tool descriptions, adding costs to your policy or setting rules such as ask when unsure.
- Medium: Tool Selection
Choosing the right tool is the most common decision an agent makes. Wrong choices usually come from unclear tools, not from a weak model.
| Problem | Fix |
|---|---|
| Two tools sound alike | Merge them or write descriptions that say when to use each |
| Too many tools (dozens) | Show only a relevant subset, found by search or by routing |
| The model skips a tool it needs | State in the instructions when a tool is required |
| The model overuses an expensive tool | Describe the cost and give a cheaper first option |
| A tool fails | Offer a fallback tool and explain it in the error message |
- Advanced: When Decisions Go Wrong
| Failure | Symptom | Mitigation |
|---|---|---|
| Overconfidence | Answers without checking | Require a tool or a source for factual claims |
| Wrong tool | Repeated irrelevant calls | Better descriptions, fewer tools, retries with feedback |
| Analysis paralysis | Endless reasoning, no action | Limit reasoning steps, set a deadline |
| Loops | Same action again and again | Detect repeats and force a different action |
| Acting when it should ask | Risky guesses | A confidence threshold: ask if nothing looks reliable |
In the code: When every option has a low chance of success, the agent chooses ask_user instead of guessing. A confidence threshold like this is one of the cheapest safety features you can add.
- Visual Explanation: Scoring Options and Switching When Things Change
The figure shows how the best action changes when conditions change, then lists the four factors behind every decision.
Click to see why asking the user can be the best actionCompare ▼
Part 1 reads left to right as three situations for the same question. Part 2 lists the factors. Open the bar to see when asking the user is the best move.
- Python Implementation: Choosing an Action by Expected Value
This script scores four possible actions with expected utility, picks the best, switches when the database is down, and asks the user when no option is reliable enough.
# Choosing an action: expected value of success minus the cost of tryingdef utility(option): return option["p_success"] * option["value"] - option["cost"] def choose(options, min_confidence=0.5): best = max(options, key=utility) if best["p_success"] < min_confidence: return "ask_user (nothing looks reliable enough)", None return best["action"], round(utility(best), 2) options = [ {"action": "answer_from_memory", "p_success": 0.55, "value": 10, "cost": 0.1}, {"action": "search_web", "p_success": 0.85, "value": 10, "cost": 1.0}, {"action": "run_database_query", "p_success": 0.90, "value": 10, "cost": 0.5}, {"action": "ask_user", "p_success": 0.95, "value": 10, "cost": 3.0},] print("Scores:", {o["action"]: round(utility(o), 2) for o in options})print("Normal day: ", choose(options)) down = [dict(o, p_success=0.0) if o["action"] == "run_database_query" else o for o in options]print("Database down: ", choose(down)) hopeless = [dict(o, p_success=0.3) for o in options if o["action"] != "ask_user"]print("Nothing reliable:", choose(hopeless))The ranking changes with the situation: the database query is chosen normally, web search takes over when the database is down, and the agent asks the user when nothing is reliable. Choosing among options with a clear rule is the heart of decision-making.
Knowledge Check
Key Points
The Big Picture
Weigh chance, value, cost and risk → pick the best action → ask when unsure
Better decisions come from clear options, clear tools and clear rules about when to stop or ask.
Up Next: Many tasks are too big to decide step by step. In Planning and Task Decomposition you will see how agents break big goals into subtasks and plan their order.