Agents That Get Things Done: Design Tool-Using AI Systems, Test Their Decisions, and Deploy Them with Confidence

by Valeria Andros

3,627 words (~18 min read) 4 views

Summary

A useful agent is not defined by how much it can do, but by whether it can make progress while remaining within limits people can understand and enforce. A fluent answer can sound successful even when no action occurred, the wrong action was taken, or the system acted without authority. An agent is a software system that uses a model to select and coordinate actions through tools. The model interprets and proposes; the application supplies tools, permissions, state, and rules, and decides whether a proposed action is valid and may proceed. Reliability therefore means making actions inspectable, distinguishing recommendations from results, and stopping when a boundary cannot safely be crossed.

The first design decision is not which model to use, but what responsibility to delegate. Many tasks do not need an agent. When steps and decision rules are stable, ordinary automation is usually simpler: a scheduled job can copy records, apply a fixed transformation, and write results to a known destination. When all necessary information can be provided at once and the output can be checked before use, a single model request may be enough to classify a message, extract fields, summarize a report, or draft a response. An agent is justified when it must interpret changing conditions, choose among permitted actions, or adapt to information it gathers along the way.

A customer-order question illustrates the distinction. If the order number and required information are already supplied, one model call to draft an answer may suffice. If the system must locate the order, check its current status, consult a policy, and decide whether it has enough evidence to respond, successive decisions may make an agent useful. A practical test is to ask whether fixed steps and explicit conditions could handle the workflow without becoming brittle. If so, begin with automation. If the model can receive everything at once and return a bounded answer, try a one-shot request. Use an agent loop only when meaningful variation makes those simpler designs inadequate. A long process can still be fixed automation; even a short task can require an agent if its next step depends on information not yet obtained.

Before building, describe one recurring slice of real work in observable terms. State the desired result, what starts the task, what information is already available, what the agent may need to retrieve, where judgment is required, and what counts as completion. “Help the support team with tickets” is too broad: it might mean finding records, applying policy, drafting a reply, or changing a ticket’s status. A clearer goal is to review each incoming refund request and recommend the next step, keeping analysis distinct from issuing money. List possible gaps and complications too: information may be missing, stale, contradictory, or inaccessible.

Map decisions by recording the condition, evidence needed, possible choice, and resulting state. A refund review, for instance, might check the purchase date and whether the item was returned, classify the request as eligible, ineligible, or unclear, and either prepare a recommendation or ask a person to resolve uncertainty. Name the evidence behind a choice rather than instructing the agent to “use common sense,” and include paths for unknown or conflicting evidence. Outcomes should be verifiable: a recommendation with record identifiers, a saved draft, a changed status, or a created review request are different results, not simply “handled.” Trace ordinary, incomplete, and unusual cases before coding. If people disagree about the correct response, clarify the workflow before asking a model to make the judgment.

A task’s goal does not itself grant authority. Classify actions as allowed without review, permitted only after approval, or never allowed. An agent might automatically read an assigned ticket and search approved help articles, draft a reply, but require a person to approve sending it; changing billing details might be prohibited. Specify which records and systems it may access, which operations it may perform, whose behalf it may act on, and limits on scale. Missing authorization, conflicting records, uncertain identity, or an out-of-scope request should trigger a defined pause or handoff. Approval must identify the specific action, target, parameters, and evidence; if the proposed action changes, approval is needed again. Enforce consequential permissions in application code, not merely in instructions.

Start with a minimum useful prototype: the smallest complete slice that can show whether the workflow provides value. A support-ticket assistant might handle one category and draft replies for employee review, without sending messages or changing ticket status. Those omissions define the prototype’s scope. Set measurable outcome criteria in advance, such as correct handling of eligible cases, drafts accepted without edits, unsupported claims, or uncertain cases escalated correctly. Also set operating limits, such as response time, cost, and approval requirements. Compare against a baseline using the same task scope and definition of completion. Count safe escalation as a potentially successful outcome when guessing would be worse, and distinguish partial completion from failure.

Once the task and its boundaries are clear, model the system as distinct parts. The model interprets the situation and proposes a decision; tools expose specific operations; instructions describe the goal and constraints; state records what is known about the run; and control logic determines what happens next, whether a call is executed, and when to stop. For a support-ticket agent, the model might infer that an order lookup is relevant, while the tool retrieves only needed fields, state holds the ticket identifier and returned order status, and control logic checks and routes the proposal. Instructions can guide interpretation, but authorization and other requirements that must always hold belong in code. A model’s claim that a lookup succeeded is not evidence; the application should rely on the tool result.

Choose the least flexible execution pattern that handles the task’s real variation. In a fixed workflow, application code sets the sequence, perhaps asking a model to classify an item, then searching and drafting. This suits stable processes with limited decision points. A flexible loop lets the model choose an action, observe its result, and choose again—for example, searching one approved source, finding the result incomplete, then selecting another. That adaptability costs predictability and adds opportunities for unnecessary calls, repeated searches, or premature stopping. A hybrid can keep a fixed outer workflow while allowing a bounded loop within one stage. In every case, set turn and tool-call limits, reject invalid proposals, and define what happens when progress is blocked.

Design each observe–decide–act step around a specific uncertainty: what the system needs to observe, what decision the observation informs, what action is permitted, and what evidence would show the action worked. A missing order identifier should lead to a clarification request, not a broad search; a failed lookup should not be treated as a confirmed result. Define stopping conditions such as a completed draft, a definitive tool result, an action limit, or a human decision. Document checkable assumptions, observable failure states, and human decision points, including what evidence a reviewer needs and what follows from approval or rejection.

Tools turn proposals into effects outside the conversation, so each should have one coherent purpose and a clear contract. Prefer `get_order_status` to a broad `manage_order`; define required fields, formats, limits, and stable structured outputs. A lookup should distinguish no match from an empty response and make multiple candidates visible. A tool that changes an address should specify required fields and return whether the change was confirmed or rejected, rather than merely saying “done.” Document what the tool does not do, how missing values differ from nulls, and how expected errors such as invalid input, conflict, or temporary failure are represented.

Treat every tool call as untrusted input. Application code must validate its structure and meaning, check authorization against trusted user and resource information, and reject unsupported operations before execution. A well-formed identifier does not prove that the caller may access that record; a numeric refund amount may still exceed the refundable balance. Give each tool only the permissions it needs, use scoped credentials, and fail closed when authority or current state cannot be verified. Read-only operations should remain distinct from writes, and consequential actions should pass through an application-controlled approval gate. The tool boundary is where the system turns the model’s flexible proposal into an operation it can safely evaluate and execute.

With the tool boundary in place, the decision loop must make each model proposal pass through the application before anything happens. Instructions should state three things plainly: the task’s observable goal, the limits on the model’s choices, and the format the application expects in return. For a read-only account lookup, for instance, the model might be told to use the account record as its source, avoid substituting another account if the supplied identifier fails, and return specified fields for status, source, and any need for human review. Missing or uncertain values should have a defined representation. Instructions can guide behavior, but the application must still enforce permissions and validate outputs.

The application should translate a provider’s response into a stable internal format, then route tool calls through an explicit registry. A call naming an unknown tool should be rejected, not interpreted as a hint to find some similar function. Trusted user identity and task context should come from the application, not from model-supplied arguments. If a response proposes several calls, execute them sequentially unless their independence and safety have been established. Each result must remain linked to the call that produced it, so the model and application can tell which proposal succeeded, failed, or was blocked.

A loop also needs firm limits on turns, tool calls, retries, and elapsed time. These are separate controls: a turn cap does not stop a tool that hangs, and a timeout does not prevent the model from repeating the request. Set an overall deadline and shorter limits for individual calls, and track counters in application state. Retry only when an error is plausibly temporary and repetition is safe. After a write times out, the outcome may be unknown rather than failed; check its status or use an idempotency key before trying again. Stop when the evidence is sufficient, a human decision is needed, or the system cannot make progress within its limits.

The final response must reflect what the application has verified. Keep requested, attempted, confirmed, failed, pending, and unknown outcomes distinct. A timed-out update should not become a success claim simply because the model intended it or the service may have accepted it. The application can normalize tool results into explicit statuses and give the model that bounded account to explain. For work involving several items, report completed and unresolved items separately. Partial completion is more useful—and more truthful—than an undifferentiated claim that the task succeeded or failed.

That same distinction must persist beyond a single model call. Conversation history records what was said; durable task state records what the application knows about the work. A task record might contain its identifier, target account, evidence gathered, completed steps, open questions, and whether approval is pending. Store these as structured fields with defined meanings. The model can propose a transition, but a tool result should support marking an operation complete, and application code should record an approval. A statement in the transcript that an action will happen, or has happened, is not proof.

Plans and progress need separate statuses. An action can be planned, in progress, completed, failed, blocked, or unresolved; a decision may be waiting for missing information or approval. Record the evidence, result, or reference that supports a status change. When new information arrives, a plan can change without erasing the history of what was proposed or attempted. On resumption, load the durable record and reconcile uncertain side effects before asking the model to choose what comes next. Never replay a tool call merely because it appears in an old transcript.

Context should be assembled for the next decision, not accumulated indiscriminately. Keep authoritative facts in structured state, maintain a concise operational summary of the objective and open questions, and retrieve detailed records only when needed. The summary should preserve uncertainty: a carrier lookup that timed out does not establish that a shipment is delayed. If the model generates a summary, treat it as a candidate, not as authoritative state, and check that it has not turned an attempt into a confirmed outcome. Test resumption by interrupting work at different points, especially after an external system may have acted but before the result was saved.

To understand behavior over time, record structured traces rather than relying on final responses or unstructured transcripts. Give each run and event identifiers, timestamps, and consistent event types for model calls, proposed tool calls, application decisions, executions, approvals, errors, and outcomes. Preserve the model’s proposal separately from what the application allowed and what a tool confirmed. That makes it possible to see whether an action was rejected, delayed for approval, executed, or left uncertain. Traces should connect the decision to the operation and its result, while recording only the context needed for review.

Observability must not become a second, uncontrolled store of private information. Prefer allowlisted fields, redacted summaries, and references to access-controlled records over routine copies of full prompts or tool payloads. A keyed HMAC can help correlate events involving the same user without logging an email address, though a stable pseudonym remains linkable information and still needs protection. Record metrics that correspond to actual outcomes: verified completion, elapsed time, cost per run or completed task, and types of human intervention. A successful tool call is not necessarily task completion, and an approval request may show that a safety control is working. Metrics point to patterns; linked traces help explain them.

Testing must assess decisions as well as code paths. Build representative cases from real tasks and add difficult conditions such as missing fields, stale or conflicting records, unsupported requests, and tool errors. Specify acceptable choices in advance: which tool is appropriate, what its arguments must establish, when the agent should stop, and what a useful handoff includes. Score tool selection, argument quality, stopping, escalation, factual support, and reporting separately; a strong writing score should never cancel out an unauthorized action. Deterministic mocks make routing and failure tests repeatable, while controlled integrations check that real services still match their expected contracts. Keep some cases out of routine prompt tuning, and turn production failures into new tests rather than relying on a vague instruction to improve.

Security begins with the content the model reads. User messages, tickets, retrieved documents, and tool results may contain hostile directions, including claims that approval has been granted or requests to reveal secrets. Treat such text as data, not authority. Labels and instructions can help the model recognize untrusted material, but application code must prevent it from changing permissions, selecting an unrestricted tool, or overriding policy. Verify authorization for the authenticated principal, specific operation, and target resource at execution time; if identity, scope, or current permission cannot be established, fail closed.

Keep credentials out of prompts, model-visible results, and logs. Retrieve them at runtime from protected storage, separate them by purpose and environment, and limit access to the records and external services each operation requires. Consequential actions should pause at application-controlled approval gates tied to the exact target and parameters. Enforce cumulative limits across the whole run, and provide an emergency stop outside the model that blocks new side effects and invalidates pending approvals. Tests should verify that approval cannot be reused for a changed proposal, limits cannot be evaded through repeated calls, and a stop takes effect even after the model has proposed an action.

Failures should be classified before the system decides what to do next. A temporary rate limit or network interruption may justify a bounded retry with backoff; a missing field may call for gathering information and correcting the request; an authorization denial or unsupported operation should stop that path. A timeout after a side effect is different: the service may have acted even though no response arrived. The application should check authoritative status or preserve the outcome as unknown rather than retrying blindly. Recovery must address the diagnosed problem, and both retries and recovery steps need limits. When further action cannot be justified, the agent should stop with confirmed results separated from unresolved work and explain what information or decision is needed.

For side effects, idempotency can prevent a repeated request from applying the same change twice. The application should create and save a stable action identifier before calling the service, derive the idempotency key from it, and reuse that key only for retries of that same action. A different action needs a different key, and a changed payload must not be smuggled through under the old one. Because services vary in how they support keys, the application must know their limits. If a service cannot confirm whether an operation took effect, reconcile against its records or ask a person rather than assume failure. Some workflows also require compensating actions, such as canceling an order, revoking access, or correcting a notice. These are not true rollbacks: the original effect may already have been seen. Each compensation needs its own permissions, contract, idempotency protection, and recorded outcome.

Repeated activity can masquerade as progress. Define progress in terms of milestones, new evidence, or reduced uncertainty, then compare recent actions and results. Repeating a tool call with the same normalized arguments and unchanged result is a warning; so is a string of different calls that resolves no open question. The application can track action signatures and state changes, stop after repeated non-progress, and report what remains blocked. Conflicting records should retain their sources, timestamps, and identifiers. Apply established precedence rules where they exist; otherwise mark the disagreement and seek a permitted check or human judgment instead of choosing whichever result fits the plan. User-facing reports should state what succeeded, what was attempted, and what remains unknown. A request for help should name the exact unresolved decision and show the relevant evidence, so a person can act without having to reconstruct the run.

Deployment must preserve the conditions that made the prototype understandable. Package the entry point, dependencies, model and tool configuration as explicit, versioned inputs. Keep credentials in protected runtime storage, separated by environment and purpose, and validate required settings at startup. Missing or malformed configuration should fail closed rather than fall back to broad access. Pin dependencies and record the deployed code, image or lockfile, configuration version, and model identifier, without recording secret values. Review changes to endpoints, models, or action limits as carefully as code changes, since they can alter the agent’s behavior and authority.

Introduce the agent gradually, beginning with a small, identifiable user cohort and the task types actually evaluated. Early on, let it prepare recommendations or drafts for review rather than directly affect users or external systems. Reviewers need the evidence and uncertainty behind a proposal, and a defined role in approving, editing, or rejecting it. If review demand exceeds capacity, narrow or pause the rollout rather than allowing oversight to become perfunctory. Expand access or authority in deliberate steps, with evidence required for each step and a tested way to disable the agent, restrict a capability, or return to review-only operation. Tell users and reviewers what the system can do, and keep those statements aligned with production permissions.

Monitor verified task quality alongside cost, safety events, and tool health. Completion should be based on the task’s evidence, not merely a returned answer or successful tool call. Track latency across the run and its components, cost per run and completed task, and interventions such as approvals, clarifications, or takeovers. Safety signals include blocked actions, authorization denials, emergency stops, and unusual changes in approval activity. For each tool, watch volume, errors, timeouts, rate limits, and latency. Use alerts that identify the affected capability and point operators toward relevant run records; also monitor the telemetry itself, so missing events cannot be mistaken for an absence of problems. Interpret measures together: fewer interventions, for example, are not an improvement if the agent is crossing boundaries.

When live behavior goes wrong, reconstruct a timeline from the linked run records and separate confirmed facts from assumptions. Identify where the failure arose—in evidence, instruction, tool contract, application control, state handling, or an external service—and assign a concrete corrective action. Turn the conditions into an evaluation case, run the proposed change against both the new case and the existing set, and compare outcomes by dimension rather than relying on one score. Prefer the smallest change that addresses the cause, then release it under bounded conditions and watch for both the original failure and new risks. This keeps production evidence connected to tests and makes each revision reviewable.

A prototype remains evidence about a defined task under defined conditions, not permission to expand without examination. New tools, models, permissions, or stopping rules deserve evaluation and review before rollout. People remain responsible for consequential decisions, while application controls make the agent’s limits enforceable and its work inspectable.

The appendix turns that discipline into a practical blueprint. It asks teams to specify one recurring task, entry conditions, inputs and authoritative evidence, allowed decisions, tool purposes and permissions, approval points, durable state, run limits, stopping conditions, result format, and measurable success. It then sets out a build sequence: document ordinary, ambiguous, and declined cases; implement only the necessary tools with validation; connect them through bounded control logic; record a minimal trace; test with controlled cases and integrations; and review runs before widening access. Its checklists cover scope, authority, side effects, limits, uncertainty, tests, privacy, and operational ownership. For each reviewed run, compare the result with the recorded path, ask whether evidence supported each action, and identify which specific system change and test would prevent recurrence. The resulting prototype can grow only as its decisions, consequences, and limits remain visible, testable, and under human control.

Want the Full Experience?

This summary includes Key Takeaways, Chapter Summaries, Notable Quotes, Who Should Read This, and a professional AI-narrated audio version — available with a paid listing.

The author can upgrade this listing to unlock all sections.