← Reference · Nestor G Pestelos Jr · Print this page
Systems Architecture · Artificial Intelligence
Agentic Loops
Reference entry · last updated 20260910
An agentic loop is a repeated execution cycle in which an AI agent uses observations from its environment to choose subsequent actions toward a task.[1]
Previous version, captured 20260910
First principles and definitions
In Anthropic’s distinction, workflows follow predefined code paths; agents dynamically direct their tool use. A workflow can contain a retry loop without delegating action selection to a model.[1] Feedback can change the next action, but does not guarantee progress or a correct result.
The agent harness executes tool calls and manages the surrounding runtime. Trivedy includes orchestration logic within the harness.[2] Prompt engineering shapes instructions; context engineering determines the information available during execution.
Task and current observations
↓
Model chooses an action
↓
Harness executes an allowed tool
↓
Inspect result and stopping conditions
↺ Continue with new observations
or ↓ Stop
Completion · Budget or time exhausted · Cancellation
Unrecoverable failure · Human escalation
Worked example
This illustrative research task uses read-only tools: find the publication year of a named paper and return its source.
- The agent searches the title and receives several candidate records.
- It opens the matching publisher record to check the title and year.
- If the record describes a different edition, that observation changes its next search.
- It returns the verified year and citation, or reports the unresolved question when its search limit is reached.
The changed query demonstrates feedback-driven action selection. The example does not require a filesystem write or another external mutation.
Architecture patterns
These patterns describe different responsibilities, not ranked autonomy levels.
- ReAct interleaves reasoning and actions within a task. Human approval is a separate deployment policy.[3]
- Reflexion adds verbal reflection retained in episodic memory for later attempts. Its mechanism does not rewrite tools or update model weights.[4]
- An orchestrator can assign subtasks to workers and combine their results. An evaluator-optimizer workflow instead revises an output using evaluator feedback. Anthropic describes both patterns separately.[1]
Weng describes planning, memory, and tool use as components of an LLM-powered agent.[5]
Design considerations
Anthropic recommends starting with the simplest effective system and weighing added cost and latency against performance.[1] Task frequency affects that tradeoff; it is not a definition of an agentic loop.
- Feedback: Tests, tool results, human judgments, or model evaluations can guide another attempt. Evaluation must match the task; a passing check covers only what it measures.
- Tools: Available operations can be read-only. Mutation permissions should match the task and be enforced by the host.
- Bounds: Set limits on turns, time, and expenditure, with a defined outcome when a limit is reached.
The following stopping and recovery rules are illustrative engineering policies, not requirements of ReAct or Reflexion.
Failure modes and stopping
- Repeated failure: inspect the error, revise the plan or inputs, and cap retries. Escalate or stop when the failure remains unresolved.
- Lost task context: retain the goal and relevant evidence within the available context window. Record unresolved assumptions explicitly.
- Ambiguous tool outcomes: check whether a mutation took effect before retrying it, to avoid duplicate side effects.[6]
- Untrusted instructions: treat retrieved content as evidence. Prompt injection defenses and permission checks belong in the surrounding system; a prompt alone is not containment.
A fail-closed policy can stop restricted actions when authorization cannot be established. Cancellation, hard limits, and tool permissions should remain enforceable even when the model proposes continuing.
See also
References
- Anthropic. “Building effective agents.” 2024.
- Trivedy, Vivek. “The Anatomy of an Agent Harness.” LangChain, 2026.
- Yao, Shunyu, et al. “ReAct: Synergizing Reasoning and Acting in Language Models.” ICLR, 2023. Author project page.
- Shinn, Noah, et al. “Reflexion: Language Agents with Verbal Reinforcement Learning.” NeurIPS, 2023. Full text.
- Weng, Lilian. “LLM Powered Autonomous Agents.” 2023.
- Amazon Web Services. “Making retries safe with idempotent APIs.” Amazon Builders’ Library.