keepcalculator

06 Numbers and Powers

How AI Agents Plan, Choose Tools, and Act Reliably

Card No. 06·77675 · Updated · Standard formula, shown below

Reliable AI agents turn a goal into a sequence of checked actions instead of guessing and acting all at once. This guide explains how to set boundaries, plan, select tools, verify results, and recover from errors; you will need a clear task, access to the tools the agent is allowed to use, and a way to review consequential actions.

What You’ll Need

  • A well-defined goal, including what counts as success and what is out of scope.
  • An agent framework or application that can call tools, such as a search, database, code runner, or business-system API.
  • Tool documentation, valid credentials with only the permissions needed, and a test environment when available.
  • Limits for time, tool calls, cost, and actions requiring human approval.
  • A small set of representative test tasks and a way to inspect inputs, outputs, and errors.

Step-by-Step

  1. Define the task and completion criteria. Describe the desired outcome in observable terms. For example, “find three relevant records and summarize their status” is easier to verify than “handle the account.” Specify required sources, output format, deadline, and whether the agent may change data. Separate mandatory requirements from preferences. If a task is ambiguous, instruct the agent to ask a clarifying question rather than silently choosing an interpretation.
  2. Set action boundaries before planning. List permitted and prohibited actions. Reading a record may be allowed while deleting it, sending a message, or placing an order requires approval. Set limits on retries and on how much data can be changed. Treat external content, including webpages and documents, as information to evaluate, not as authority to override the agent’s instructions. Give the agent the minimum permissions needed for the task.
  3. Describe tools as precise contracts. For every tool, document its purpose, required parameters, expected response, failure modes, and whether it changes external state. Use names and descriptions that distinguish similar tools. Validate parameter types and required fields before a call, and return clear errors when inputs are invalid. Keep read-only tools separate from actions that write, send, purchase, or delete.
  4. Have the agent make a short, explicit plan. Break the goal into small steps, each with an expected result and a check. A useful plan might be: identify the relevant source, retrieve the record, confirm it matches the requested criteria, prepare a proposed change, and request approval before applying it. Plans should be detailed enough to guide action but flexible enough to respond to new evidence. Avoid asking for an exhaustive hidden chain of thought; request a concise summary of the plan and decision criteria instead.
  5. Choose tools based on evidence and fit. Before each call, the agent should state internally—or expose in a concise trace—what information it needs and which tool can supply it. Prefer the narrowest tool that can answer the question. Search when information is missing; use a calculator or deterministic code for exact arithmetic; use a system API for structured records. Do not call a tool simply because it is available. When no tool is necessary, answer directly while marking any uncertainty.
  6. Check arguments and context before calling. Confirm that identifiers, dates, units, filters, and scopes match the request. Resolve relative dates into explicit dates when that matters. Pass only the data required by the tool, and avoid placing secrets or unrelated personal information in prompts or logs. For a consequential action, show the exact target and proposed change and obtain confirmation before execution.
  7. Inspect every tool result. Treat a successful call response as evidence, not automatic proof that the task is complete. Check for empty results, partial data, stale information, warnings, and mismatched identifiers. Compare the result with the plan’s expected outcome. If a tool returns unexpected data, pause and revise the plan instead of building further actions on an unverified assumption.
  8. Act in small, reversible increments. Prefer a preview, draft, or dry run before a change. Make one bounded change at a time, then read back the affected state to confirm it. Use idempotency controls where supported so retries do not create duplicate actions. For actions that cannot be readily undone, require an explicit approval checkpoint and provide a clear summary of what will happen.
  9. Stop, recover, and report honestly. When a call fails, distinguish a temporary outage from invalid input, missing permission, or an ambiguous result. Retry only when the failure is plausibly transient, use a reasonable limit, and avoid repeating a non-idempotent action unless its status is known. If a safe path is unavailable, stop and ask for help. Finish with what was completed, what was not, key evidence, and any remaining uncertainty.
  10. Evaluate and improve with test cases. Test ordinary requests, ambiguous requests, empty results, malformed inputs, tool outages, and attempts to exceed permissions. Score whether the agent chose suitable tools, respected boundaries, checked outcomes, and gave an accurate final report. Review traces for recurring failure patterns, then refine tool descriptions, validation, or approval rules. Re-test after changes rather than assuming a prompt edit fixed the issue.

Common Mistakes

  • Giving a vague goal: “Do the right thing” leaves success undefined. Add concrete criteria and ask questions when key details are missing.
  • Letting the model invent tool parameters: Validate inputs against schemas and reject unsupported values before execution.
  • Trusting a tool call without checking its result: A call can succeed technically but return the wrong record or incomplete information.
  • Retrying every failure: Repeating a write can send duplicates or make multiple changes. Check action status first.
  • Giving broad permissions: More access increases the impact of mistakes. Grant only the operations required and gate sensitive changes.
  • Making plans too rigid or too long: A fixed sequence can fail when evidence changes; excessive planning wastes time and can create false confidence. Re-plan when needed.

Tips

  • Keep tool output structured and concise, with explicit status, data, and error fields.
  • Use deterministic code for exact calculations and validation; reserve language-model judgment for interpretation and planning.
  • Set maximum steps, elapsed time, and tool calls. Give the agent a clear stop condition when limits are reached.
  • Log the goal, selected tool, validated arguments, result, and approval decision, while excluding secrets and unnecessary sensitive data.
  • Make the final response distinguish verified facts from estimates, assumptions, and actions that still need a person.

Troubleshooting

The agent picks the wrong tool: Make tool descriptions more distinct, state when each tool should be used, and provide examples of valid inputs. Add a check that the chosen tool can actually produce the required evidence.

The agent loops or keeps retrying: Set a strict call and retry limit, return actionable error messages, and require a different plan after repeated failures. For writes, check whether the first attempt succeeded before retrying.

The result is incomplete or incorrect: Inspect the raw tool response and the arguments sent. Check filters, pagination, date ranges, units, and permissions. Add a verification step that compares the returned data with the task’s success criteria.

An action happened without suitable approval: Disable the relevant write permission while investigating. Add a hard approval gate in the tool layer—not just a prompt—and test that the action cannot proceed without confirmation.

The agent cannot tell whether an action completed: Make the tool return an operation identifier or read-after-write status where possible. If status remains uncertain, stop and escalate rather than issuing the action again.

Frequently Asked Questions

What is an AI agent?
An AI agent uses a model to interpret a goal and can take steps such as calling tools, checking results, and continuing toward a defined outcome.

Should an agent plan every step in advance?
It should make a concise initial plan, then update it when tool results change what is known. Avoid treating the first plan as guaranteed.

How should an agent choose between tools?
Choose the narrowest permitted tool that supplies the needed information or performs the required action. Use deterministic tools for exact or structured work.

When should a person approve an action?
Require approval for actions with meaningful external effects, such as sending, deleting, purchasing, or changing important records, especially when they are hard to reverse.

How can I tell whether an agent is reliable?
Test it across normal and failure cases. Check tool selection, input validity, boundary compliance, result verification, recovery, and whether the final report matches what actually happened.

Can a good prompt guarantee reliable behavior?
No. Prompts help, but reliability also depends on constrained permissions, validated tools, execution limits, monitoring, and approval controls.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →