OpenViSTAI · Agents · Blockchain · Crypto
Menu
OPENVIST JOURNAL

A Practical Anatomy of an AI Agent: Tools, State, Permissions and Recovery

An AI agent is more than a model with a tool list. It is a system that selects actions, observes results, manages state and operates within boundaries. Here is how to design that system so it can make progress without making unchecked decisions.

8 min readAll articles →
A Practical Anatomy of an AI Agent: Tools, State, Permissions and Recovery — editorial illustration about AI Agents

A chatbot answers a prompt. An agent can take a sequence of actions toward a goal: inspect a project, call an approved tool, read the result, and decide what to do next. The distinction is not a label or a particular model. It is a control loop whose actions affect an environment and whose next step depends on what happened.

That loop creates engineering responsibilities. Tool calls need defined inputs and limits; state needs a lifecycle; failures need recovery rules; and consequential actions need checkpoints. Treating these as explicit parts of the design makes an agent easier to test and safer to operate.

Start with the control loop, not the model

A useful minimal agent loop has five stages: receive a goal, choose an action, execute it, inspect the result, and choose whether to continue, stop, or ask for help. The model may propose an action, but the surrounding application decides whether that action is available and whether its arguments are acceptable.

For example, a repository assistant might be asked to fix a failing test. It can inspect files, propose an edit, run the test command, and use the output to decide whether another change is needed. This differs from simply generating a patch: the agent observes the effect of its work and can adjust its next step.

Make the loop visible in code and logs. Record the goal, each proposed action, the tool result, and the reason for stopping. Without this trace, it is difficult to distinguish a bad model decision from a broken tool, incomplete context, or an overly permissive execution layer.

Tools define the agent’s real reach

A tool is an interface through which the agent can affect or inspect something outside its own response. It might read a file, invoke a Java method, query an API, run a test, or submit a transaction. The model’s apparent capability matters less than the operations exposed to it.

Prefer narrow, task-shaped tools over a broad escape hatch. A function such as create_support_ticket can validate required fields and restrict destinations. A generic shell tool can potentially do much more, so it needs stronger isolation, command constraints, and review. The right boundary depends on the environment and the consequence of misuse.

Frameworks can help connect language to actions, but they do not remove the need to design tool contracts. For instance, Tools4Ai is a Java framework for connecting natural-language prompts to Java methods and external or enterprise tools. That makes it relevant when a builder wants approved application methods to become agent actions; the application still needs to specify which methods are exposed and how their inputs are checked.

For every tool, document its input schema, side effects, failure modes, and authority. A read-only lookup should be distinguishable from an operation that changes data. If a tool can spend money, publish content, delete records, or alter permissions, make that consequence apparent to both the agent runtime and the human reviewing its proposed action.

State needs scope, ownership and expiry

Agents need state to continue a multi-step task, but “memory” can refer to several different things. Short-lived execution state tracks facts such as the current step or a tool result. Durable project memory preserves information across sessions. Mixing these without an explicit policy can lead to stale assumptions, accidental disclosure, or decisions based on context that no longer applies.

Keep task state bounded to the current run where possible. Store durable information only when there is a clear reason, such as a project decision that will matter again. Record where a memory came from and when it was created; provide a way to inspect or remove it. These practices make retrieval more accountable than treating every past interaction as equally relevant.

A local memory system such as SAGE illustrates one pattern: authorized agents can save decisions, failed approaches, and lessons to a shared node and recall them in later sessions, with a dashboard for inspecting stored experience. This can help a coding assistant avoid repeating project-specific mistakes, but retrieved notes should still be treated as context to verify, not unquestionable instructions.

Before adding persistent memory, ask what should be retained, who can read it, and how long it remains useful. A temporary test result may belong only in the current run. A project convention may be worth retaining, provided an owner can correct it when the convention changes.

Permissions should follow the action’s consequences

Authorization is not a single “agent enabled” switch. Separate what the agent may observe from what it may change, and separate low-impact changes from actions that are difficult to reverse. A read-only repository inspection and a live trade should not receive the same permission by default.

Use least privilege: expose only the tools needed for a task, scope credentials to the necessary resources, and validate tool arguments independently of the model. Where feasible, make sensitive actions require a separate approval step. The approval should show the proposed operation and its important parameters, rather than asking a person to approve an opaque “continue” request.

Trading systems make the difference concrete. Crypto Trading Arena is described as a multi-agent environment that consumes live ticker and candlestick data, accesses portfolio and calculator tools, and executes trades autonomously. That setup is useful for thinking about how data access, analysis tools, and execution fit into one workflow. The described autonomous execution does not establish that a simulated mode is available, so a builder evaluating strategies should not assume paper trading without implementing or verifying it separately.

For any action with material external effects, define a checkpoint policy before deployment. A human might approve each action, approve a bounded batch, or approve a plan while the system executes only operations inside a specified envelope. The choice should be based on reversibility, impact, and the cost of a mistaken action.

Retries need limits and a recovery path

Tool calls fail for ordinary reasons: a network timeout, malformed input, a rate limit, or a changed external system. An agent that retries without a policy can repeat side effects or spend its entire run cycling through the same error. A retry is a control decision, not a substitute for understanding the failure.

Classify failures before deciding what to do. A transient read timeout may justify a limited retry. A validation error calls for corrected input, not an identical request. An ambiguous result from a side-effecting operation requires checking whether the operation already happened before attempting it again. Where the external system supports idempotency keys, use them to reduce the risk of duplicate effects.

Give each run a budget: a maximum number of steps, tool calls, elapsed time, or other resource limit appropriate to the task. Define terminal states such as completed, blocked, failed, and awaiting approval. When the agent reaches a limit or cannot establish what happened, it should report the uncertainty and stop rather than inventing success.

Evaluation should test behavior, not fluent answers

An agent evaluation should measure whether the system reaches an acceptable outcome through permitted actions. A polished explanation can conceal a failed task, while a short response may follow a correct sequence. Test tool selection, argument validity, recovery, permission boundaries, and the quality of the final handoff.

Build a small set of repeatable cases from real tasks. Include a normal path, a tool error, incomplete input, a request that exceeds the agent’s authority, and a case where a human checkpoint is required. For each case, define observable pass conditions: the expected state change, the absence of a prohibited action, or a clear escalation when the task cannot be completed.

Keep evaluation separate from live side effects. A coding agent such as Alphacode is described as reading code, editing files, running commands and tests, and automating browser and desktop interactions. Those capabilities suggest a practical evaluation workflow—use a controlled project and inspect the resulting diff and test output—but do not by themselves establish a sandbox or a particular safety configuration. Builders need to supply appropriate isolation and review boundaries.

Inspect traces as well as outcomes. A correct result reached through an unauthorized action is not a pass. A failed attempt that detects a blocked operation and asks for approval may be the desired behavior. This is why evaluations need explicit criteria for both what the agent accomplishes and how it gets there.

Choose autonomy per workflow, then iterate

Start with a task whose boundaries are understandable and whose outcome can be checked. Give the agent the smallest useful set of tools, keep execution state short-lived, and require approval for consequential actions. Once traces show where it succeeds and fails, expand its authority only when the evidence supports that change.

Autonomy is a workflow decision. A system may be allowed to gather information and prepare a proposed change, but not apply it. It may run tests independently while requiring approval to merge. These boundaries can be adjusted without changing the underlying model, because they live in the tools, permissions, checkpoints, and runtime policy.

The practical test for an agent is therefore not whether it can call a tool. It is whether the complete system can select an appropriate action, remain within its authority, interpret the result, recover from expected failures, and expose enough evidence for a person to trust or correct its work.

Reuse this article’s text

OpenViST’s original editorial text is available under CC BY 4.0, unless a specific notice states otherwise. You may share and adapt it, including commercially, with credit, a source link, a licence link and a description of changes. This covers only rights OpenViST can license. Images, third-party quotations, screenshots, logos and other excluded material require their own permission or applicable legal basis.

Attribution example for unchanged text:

“A Practical Anatomy of an AI Agent: Tools, State, Permissions and Recovery” — OpenViST. Source: https://openvist.com/a-practical-anatomy-of-an-ai-agent-tools-state-permissions-and-recovery/. Licensed under CC BY 4.0. Changes: none.

If you translate, shorten or adapt the text, replace “Changes: none” with what you changed and retain any separately required author attribution and notices. See the reuse guide and adaptation example.