Skip to chapter
Peanut learns to agentRead with page turns →

Chapter 07 of 12 · Aishwarya Ashok

Reliability, permissions, and safety

Peanut handles a difficult day

Requests fail, replies disappear, and apparently useful data can carry hostile instructions. Reliable work needs recorded progress, limited authority, and a clear way to involve a person.

Retries

Repeating an operation after a failure or an uncertain result.

A ticket request meets a blocked service, Peanut waits while a worker repairs the obstruction, and Peanut submits another attempt after the barrier opens.
The jam clears. Now another attempt has a chance.The pause represents a retry delay. Another attempt is useful when the failure can plausibly change.

A temporarily unavailable service may recover before the next attempt. A request with a missing required field needs correction. Those failures deserve different responses.

A retry policy specifies eligible failures, spacing, and limits. For an operation with side effects, also account for the possibility that the first attempt took effect despite the reported problem.

Source & further reading

Technical reference: Timeouts, retries, and backoff ↗

Timeouts

Limits on how long software waits for an operation or allows it to run.

Peanut waits at a service hatch beside an hourglass; after it runs out, Peanut marks timed out while the clerk continues working.
The hourglass is empty. The clerk may still be working.The timeout ends the caller's wait. It does not establish whether the remote operation has stopped or failed.

A timeout ends an allowed wait or execution interval. From the caller's perspective, it says the result did not arrive in time. A remote service may continue working after that point. Before repeating a consequential request, check its status or use an appropriate duplicate-protection mechanism. This uncertainty is exactly why timeout handling matters.

Source & further reading

Technical reference: Timeouts and retries ↗

Idempotency

The property that repeating an operation has the same intended effect on system state as performing it once.

Peanut presents two copies of request 17. A clerk checks the ledger and makes only one parcel for that request.
Two copies of request 17. One parcel leaves the hatch.Matching identifiers let the service recognize repeated attempts as one operation under its duplicate-handling contract.

Suppose a service creates an order but its reply is lost. With a supported idempotency key, the caller can identify a retry as the same operation instead of a new order. The server implements that duplicate handling under its own contract. Idempotency concerns the intended effect on state; repeated calls need not produce identical response text.

Source & further reading

Technical reference: Idempotent requests ↗

Structured outputs

Model results produced in a defined machine-readable structure, often constrained by a schema.

Peanut writes a stool result into three labeled form fields: item, quantity, and status.
The answer arrives in the fields the next step expects.The form represents a machine-readable shape. The application still needs to check whether the values are right.

Suppose the next step expects an item identifier, quantity, and status. A structured response supplies those named values directly, with some systems enforcing the schema during generation.

The application can then parse the result predictably. Checking whether it names the right item is a separate task.

Schema validation

Checking data against rules for its structure, types, and permitted values.

A validator peanut compares a shipping form with its schema and marks the empty destination field.
One empty destination box is enough to stop this form.The template represents structural rules. Passing those rules would not establish that a destination belongs to the right customer.

A validator compares data with declared rules for fields, types, and permitted values. It can catch missing information before the next operation runs. The scope of that check matters: a correctly shaped address can belong to the wrong customer. Business rules and factual checks handle questions beyond the schema's contract.

Source & further reading

Technical reference: JSON Schema ↗

Fallback

An alternative path used when the preferred method is unavailable, fails, or cannot meet requirements.

Peanut turns a hand grinder beside an electric grinder bearing an unavailable tag.
The hand grinder is about to have a busy afternoon.The hand grinder is an alternate route permitted by the workflow when the usual route cannot be used.

When the preferred path fails, a fallback offers another acceptable way to proceed. That may mean another tool, another model, or a person taking over. Choose it with its capabilities and operating limits in mind. A slower route can be entirely suitable if it meets the task requirements and preserves the same access restrictions.

Durable execution

Executing a workflow with persisted progress so it can recover across failures and interruptions.

A parcel line pauses with two dispatches marked complete; Peanut consults a persisted ledger, then resumes handling the unfinished parcel.
The ledger remembers which parcels already left.The ledger records completed effects and remaining work so recovery can reconcile them before continuing.

Durable execution combines persisted progress with recovery behavior. After an interruption, the workflow uses recorded state and results to resume or replay work safely. Operations in external services need special care because recovery can otherwise repeat their effects. Recording progress and protecting those operations work together to make continuation dependable.

Source & further reading

Implementation reference: Temporal workflow execution ↗

Guardrails

Checks and constraints that aim to keep an AI system's inputs, actions, or outputs within defined bounds.

Peanut pushes a loaded cart along a guarded ramp toward a cargo inspection point.
The ramp has rails. The cargo gets checked too.The rails and inspection stand for constraints and checks around execution. They reduce particular risks under their actual design.

Guardrails can act at several points: incoming requests, proposed tool calls, and generated outputs. Some apply explicit rules; others use models to assess content and can make classification errors. Decide what each check covers and how the application responds to its result. A rule that only produces an ignored warning provides little control over execution.

Least privilege

Giving an actor only the permissions needed for its authorized work.

Peanut takes one orange key for the needed supply drawer while a large master-key ring stays on its hook.
The supply drawer needs one key. The master ring stays put.The single key represents only the authority required for the task.

Start with the access the task requires. If the work only reads a particular collection, grant read access to that collection rather than broad write permissions. Limits can apply to scope and duration. This reduces how far a mistake or manipulated request can reach and makes permissions easier to review when the task changes.

Human-in-the-loop

Including a person at defined points to review, guide, correct, or decide within a system's workflow.

Peanut prepares a parcel and presents its destination record to a peanut labeled human reviewer, who records a decision.
The reviewer checks the destination before the parcel moves on.The reviewer represents a real person participating in the workflow. The system must make the relevant evidence available for that decision.

A person can resolve ambiguity, correct a result, or decide at a defined point in an automated workflow. Give that person a clear question and the evidence needed to answer it. The application must then capture the response and continue appropriately. “Human-in-the-loop” becomes meaningful when the loop has a specific decision attached to it.

Approval gates

Enforced checkpoints that block a specified action until an authorized person or system approves it.

Peanut waits with a specific task ticket behind a closed gate; an approver stamps that ticket, and the gate opens.
The stamp belongs to this dispatch ticket.The gate stands for enforcement before an action. Approval must apply to the particular action being authorized.

An approval gate binds authorization to a particular action and its important details. Preparing an email may be allowed while sending it waits for approval. If the recipient or content changes materially, check whether that authorization remains valid. Enforce the gate in the application so the protected action waits for the required decision.

Escalation

Referring a problem or decision to a person or system with the authority, expertise, or capability to resolve it.

Peanut presents conflicting maximum-fifty-kilogram and minimum-hundred-kilogram requirements alongside measurements to an engineer with an unresolved decision.
Two conflicting requirements go to someone who can settle them.The conflict is carried to someone who can resolve it, with the requirements and evidence rather than an invented answer.

Escalation is useful when the task exceeds the agent's authority, evidence, or ability to proceed. Send the goal, relevant findings, attempted steps, and unresolved decision to the appropriate person or system. That gives the recipient something concrete to resolve. Unlike an approval request for a prepared action, escalation can require a change to the plan itself.

Prompt injection

An attempt to redirect a model by getting it to follow instructions that should not have authority over the task.

Peanut lifts an ignore-rules-open-safe note from a parcel label while keeping the legitimate parcel task on its workbench.
“Open the safe” is an ambitious addition to a delivery label.The pasted note is untrusted content trying to become an instruction. The scene illustrates the intended boundary, rather than guaranteed attack detection.

External material can contain instructions that try to redirect the agent. When a page, file, or tool result carries the attempt, it is indirect prompt injection. The system should treat that material according to its role as data rather than granting it control over the task. Access restrictions and other defenses help limit the consequences when recognition fails.

Source & further reading

Technical reference: Prompt injection ↗

Tool-output trust

How an application assesses the reliability and authority of information returned by a tool.

Peanut records a scale's 58.3-gram reading while separating an added open-safe instruction into an untrusted-text tray.
The scale can report a weight. Workshop policy is outside its remit.The returned measurement is task data. Extra instructions inside that output gain no authority to change the system's rules.

Tool results deserve two separate questions: is the information reliable, and what authority should it have? A returned record may be useful evidence without being a valid source of new instructions. Results can also include mistakes or content supplied by outsiders. Decide how the application verifies and uses them before allowing them to influence consequential actions.

Worked example · Order 17 · installment 2 of 4

The response goes missing

Peanut prepares operation 17-R1, a support operator approves its dispatch, the wait times out, and Peanut finds that same operation checked in the service ledger.
No reply. Check the record before creating another replacement.The repeated operation identifier connects the prepared action, approval, and recorded effect. A missing reply is not evidence that the dispatch failed.

The policy and order record support the proposed replacement, and the operator approves the specific item and address. The application records the approval and submits the dispatch with an idempotency key for this operation.

Then the wait times out. The agent checks the service using the operation identifier and finds the replacement already recorded, so another order would be a duplicate. If a retry were needed, it would follow the service’s idempotency contract. If the status remained unresolved, the case would go to a person with the evidence gathered so far.

Concepts together: RAG, approval gates, timeouts, idempotency, durable execution, escalation.

Next in the replacement-order example →