How do AI agents work? The loop, step by step
AI agents work by running a language model in a loop. On each turn the model reads the goal and everything it has learned so far, chooses an action such as searching, editing a file or calling an app, runs it, reads the result, and decides whether the job is done, needs a person or needs another step. Anthropic, which makes the Claude models, describes agents as "systems where LLMs dynamically direct their own processes and tool usage". A fixed workflow, by contrast, follows "predefined code paths" (Building effective agents, December 2024).
The loop, one step at a time
1. Read the goal and the context. The model gets the request, any instructions that apply, the conversation so far and the results of earlier steps. That is everything it knows. Anything else, it has to go and look up.
2. Choose an action. The model picks a tool and fills in its inputs: a search query, a file path, a command, an email draft.
3. Act. The tool runs outside the model, for real. A file is written, a command runs, a record changes in a CRM.
4. Read the result. The tool's output comes back into the model's context. Anthropic's guide calls this getting "ground truth" from the environment at each step. Without it, the model can only guess whether the action worked.
5. Decide what happens next. Take another action, ask a person for a decision, or stop and report.
The model doesn't remember anything between steps. What carries the work forward is the growing context: the request, plus every action and result so far.
What an agent's tools are
An agent can only do what its tools allow. They usually come in three groups:
- Built-in tools for files, shell commands, a browser and web requests.
- Connected apps, often through the Model Context Protocol (MCP), a standard way for an agent to call Gmail, Slack, a CRM or any other app that has an MCP server. Our MCP explainer covers the protocol.
- Skills, which are written instructions for one kind of job. Before replying, a Neotask agent checks its list of skills, and if one clearly matches the request it reads that skill and follows it.
How Neotask's agents run the loop
Where the work comes from
Some work arrives as a request in chat. In a company workspace, most of it comes from the plan. Neotask turns the company's goals into tasks and gives each one an owner: the agent best suited to it, or the company's main agent when no specialist is clearly better. A regular check called the heartbeat sees which tasks are due and starts them, with the priority you set ranking first.
Acting instead of describing
A common failure is an agent that writes a careful plan and then stops. Neotask's runtime tells its agents to act on an actionable request in the same turn and to keep going until the work is done or genuinely blocked. If a turn only describes a plan, the agent is sent back with an instruction to take the first concrete action, or to name the one blocker in a sentence.
The same instructions cover a weak or empty tool result: try a different query, path or source before giving up. Anything that can change, such as files, versions or a service's state, gets checked live rather than assumed.
Proving the task is done
Every scheduled company task ends with one of three outcomes: success, needs input from a person, or failed.
Success has to come with evidence: a one-sentence summary of the outcome, what the task produced (file paths, links, message IDs) and the receipts it relied on. A task reported as done without evidence is not marked complete. It is held for its owner to look at.
Some tasks are checks, such as "confirm the payment arrived" or "make sure the page is live". The agent checks once and reports met, not yet met, or cannot pass, and it is told never to repeat a check with small variations in the same run. Not yet met ends the run and books a re-check: the first after 15 minutes, each one after that twice as long, at most 6 hours apart, up to 5 re-checks within 72 hours. After that, the task's owner is told. Cannot pass starts a repair, or asks the owner.

For code, the evidence is usually a test, build or lint run, or an inspection of the result. Neotask Code reads the relevant files, edits them, runs commands to check its work and shows every change.
Using a screen
When a company agent has to work through a screen instead of an app's API, it takes a screenshot before acting and another afterwards to check the result. It is told never to click a permission, password or payment dialog and never to type a secret.
Asking a person
Every action has a risk level, from read-only work up to irreversible or destructive operations, and each company's approval mode decides which levels run on their own. A blocked agent is told to try a fallback path first. If it is still blocked, it creates an item for you to act on. If the next step is risky but possible, it creates an approval, and the work picks up once you decide. Each decision records who made it: you, a rule you set, the mode, the automatic reviewer or one of the fixed checks that always apply. The AI agent security guide explains the modes and checks.
Surviving a restart
If the app or computer restarts mid-task, the setting "Continue work after restarts", which is on by default, picks the work back up. A scheduled company task resumes at most 5 times in a row before it stops. A restart never approves anything, so work that was waiting for approval keeps waiting.
Keeping a record
Each run leaves an entry in the company's activity feed with the agent's summary, the tool calls it made, how long it took, the model provider it used and the record of any approval decision. That is where you see what an agent actually did.
Two risks the loop doesn't solve
The rules above deal with agents that stop early, repeat a check or claim success without proof. Two risks sit outside the loop:
- Instructions hidden in content. A web page or email can contain text written to steer the model. OWASP lists this, prompt injection, first in its 2025 Top 10 for language model applications (OWASP LLM01:2025, read November 2026). Neotask's runtime wraps content from emails, webhooks and web pages in markers that label it untrusted before the model sees it, and keeps risky actions behind approval.
- Too much access. Whatever the agent's tools can do, a mistake can do too. OWASP's advice is to give the model only the access it needs and to put a person in the loop for privileged actions, which is what Neotask's per-app rules and approval modes are for.
If a task runs the same way every time, a fixed workflow may suit it better. Our post on agentic workflows covers when to use which, and AI agent orchestration covers what happens when one agent hands work to several others.
Frequently asked questions
What is the difference between an AI agent and a chatbot? A chatbot answers from what the model already knows. An agent takes actions with tools, reads the results and keeps going until the task is done.
Do AI agents remember things? Within one task, yes, through the context: the request plus every step and result so far. Across tasks, only if the system stores memory outside the model, such as notes, documents or learned skills. Our post on AI agent memory covers how.
Can an AI agent act without my approval? Only for the actions your settings allow. In Neotask, each company's approval mode sets which risk levels run on their own, and payments and a short list of other actions always ask a person.
Do I need to code to use an AI agent? No. In Neotask you describe the goal in plain language, and the agent picks the tools.