An AI agent is a system where a language model decides what happens next. It receives a goal, chooses an action, has a tool carry it out, observes the result, and repeats. No developer writes the sequence of steps in advance; the model chooses each one at runtime.
"Software programs that can interact with their environment, receive information, and undertake self-directed actions in service of a larger, externally-specified goal."
Source: NIST AI 100-2e2025, glossary definition of "agent"
This property, dynamic control flow, separates an agent from other LLM applications. A pipeline that always searches, then summarizes, then answers is a program with a model inside it, however sophisticated its prompts are.
The two have different operational profiles. A fixed pipeline has bounded cost, predictable latency, and testable behavior. An agent has none of those by default, and getting them back is most of the engineering work.
Agents vs. workflows
Anthropic's Building Effective Agents draws the line clearly: workflows orchestrate models and tools through predefined code paths, while agents let models dynamically direct their own processes and tool usage.
| Workflow | Agent | |
|---|---|---|
| Control flow | Written by the developer | Chosen by the model at runtime |
| Step count | Known before execution | Unknown, bounded only by a cap |
| Cost per request | Predictable | Variable, since step count varies |
| Failure mode | A step errors | The loop wanders, repeats, or stops early |
| Testing | Deterministic given fixed inputs | Requires repeated sampling |
| Right for | Well-defined tasks with stable structure | Open-ended tasks where the path cannot be enumerated |
Start with the simplest thing that works, which is also Anthropic's recommendation. If a task described as "agentic" is really a workflow with a routing step, building it as a workflow makes it cheaper, faster, and easier to debug. Reach for a true agent when valid paths are too numerous to enumerate, such as debugging an unfamiliar codebase or researching an open question.
The agent loop
Whatever the framework, an agent reduces to the same cycle.
The model never executes anything itself. It returns a structured call that your application runs, or that the provider runs for server-side tools (Anthropic tool use docs), the mechanism described in function calling. Each turn's input contains all previous conversation history (Anthropic context window docs), so every iteration resends the growing history and cumulative input tokens grow faster than the step count. The dotted line is required. Without a hard stop, a confused agent loops until it exhausts its context window or your budget.
Agent architecture
An agent has four components. Most of the engineering goes into memory and orchestration.
- Model: the decision maker, which sets the ceiling on everything else. In a loop, one plausible wrong action does not stay contained, because every later step reasons over its output.
- Tools: the action space. What an agent can do is exactly the set of tools it holds.
- Memory: what the agent knows now versus what it knew before.
- Orchestration: the loop, plus the caps, retries, and termination conditions that bound it.
Agent tools
Tool definitions deserve as much care as the prompt. For its SWE-bench agent, Anthropic reports that it spent more time optimizing its tools than the overall prompt.
Keep the tool set small. Anthropic's docs note that Claude's ability to pick the right tool degrades once you exceed 30 to 50 available tools, and descriptions begin to overlap. If two tools need a paragraph to distinguish, the model will confuse them too.
Scope permissions per tool, not per agent. A read-only lookup tool should hold read-only credentials, in line with OWASP's advice to limit extension permissions to the minimum necessary. When an injected instruction reaches the model through a retrieved document, the credential attached to the tool is the control that still holds. Guardrails can block the injection; they do not replace scoped credentials.
The Model Context Protocol is an open standard for connecting AI applications to external systems, so a capability built once as an MCP server works with any MCP-capable agent. It also widens the action space quickly, which is why per-key control over which MCP tools are exposed matters past a handful of servers. The MCP gateway is where that filtering, approval, and audit trail live in practice.
Agent memory
Agent memory is a retrieval problem. Beyond what it learned in training, everything the model knows about the task must be in the context window for that step, so memory splits into two layers:
| Working memory | Persistent memory | |
|---|---|---|
| Where it lives | The context window | Vector store, database, or files |
| Lifetime | One request | Across sessions |
| Capacity | Up to 1M tokens on some models (Anthropic); recall degrades as token count grows | Effectively unbounded |
| Cost | Billed on every step | Storage plus one retrieval per step |
| Failure mode | Truncation, or degraded attention over long context | Retrieving the wrong thing, or nothing |
Persistent memory is useful only when something selects the right fragments and injects them into working memory, which is retrieval-augmented generation applied to the agent's own history. One failure to design against is retrieving a stale fact that has since been superseded, then acting on it confidently.
Appending every tool result to history is why long runs get slow and expensive. On long runs, compaction and tool result clearing, which summarize older turns or drop raw tool output the agent no longer needs, keep cost and attention in check.
Planning patterns
- ReAct interleaves reasoning traces with actions, so the model states its rationale before each tool call. Yao et al., who introduced it, report better task performance and improved human interpretability over methods without the reasoning or acting components.
- Reflection adds self-critique after failure. Reflexion has the agent reflect verbally on task feedback, keep that reflective text in an episodic memory buffer, and retry, so it depends on the feedback signal being reliable.
- Plan-and-execute generates a plan up front, then executes against it. ReWOO (Xu et al., 2023) detaches the reasoning process from tool observations to cut token use. The trade-off is that a fixed plan cannot react to a surprising tool result unless something triggers replanning.
Reasoning models blur these patterns. OpenAI's reasoning best practices say that prompting them to "think step by step" is unnecessary and can sometimes hinder performance, so an explicit ReAct scaffold on top may duplicate work. Test rather than assume.
Multi-agent systems
A multi-agent system splits work across specialized agents, usually an orchestrator delegating to subagents.
Multi-agent setups help only under specific conditions.
| Multi-agent helps when | Multi-agent hurts when |
|---|---|
| Subtasks are genuinely parallel and independent | Steps are sequential and each depends on the last |
| Each subagent needs a different, large tool set | One agent could hold all the tools without confusion |
| Subtasks need isolated context to avoid interference | Handoffs lose context that the next agent needs |
| Task value justifies the token cost | Cost or latency is a binding constraint |
Anthropic reported that in its multi-agent research system, multi-agent systems used about 15 times the tokens of a chat interaction, against about 4 times for a single agent, and that they need tasks valuable enough to pay for the increased performance. Coordination adds its own failure class: the same post describes subagents duplicating work and leaving gaps without detailed task descriptions. Frameworks such as Microsoft Agent Framework, the successor to AutoGen, make these topologies easy to build, so check the conditions above before reaching for one.
Why agents fail in production
Agent reliability degrades multiplicatively. If each step succeeds independently with probability p, an n-step task succeeds with probability p^n.
| Per-step success rate | 5 steps | 10 steps | 20 steps |
|---|---|---|---|
| 90% | 59% | 35% | 12% |
| 95% | 77% | 60% | 36% |
| 99% | 95% | 90% | 82% |
A 95 percent per-step success rate, excellent in isolation, produces roughly a 60 percent task success rate over ten steps. That compounding argues for shorter loops, verification steps that catch errors before they propagate, and checkpoints an agent can resume from.
Latency accumulates, since ten sequential model calls are ten round trips. Cost is unbounded by default, because nothing in the loop tracks what it has already spent. Non-determinism breaks conventional testing, since the same input can yield different action sequences, so one passing run proves nothing.
Agent observability
Request-level logging isn't enough for agents. Traces must be step-level, with a span per model call and per tool execution, linked under one trace ID for the run. OpenTelemetry's GenAI agent span conventions define invoke_agent and execute_tool operations for this.
Metrics that diagnose problems:
- Steps per task, as a distribution rather than a mean. A long tail means the agent is getting stuck.
- Tool selection accuracy and argument validity rate, which depend on tool definitions you control.
- Cost and tokens per completed task, not per request.
- Termination reason: completed, iteration cap, budget cap, or error. A rising share of cap-triggered stops is an early warning.
See LLM observability for instrumentation patterns.
Operational controls
A single user action can produce bursty, multi-step, multi-tool traffic, a pattern that quotas sized for chat do not anticipate. The controls that bound an agent belong at the boundary, not in application code where every team reimplements them differently.
Bifrost sits at this boundary. A virtual key gives each agent its own credential. Budgets and rate limits stop a runaway loop once its allowance is used up. Per-key MCP tool filtering is deny-by-default, so an agent sees only the tools its key allows. Tool calls don't run until your app executes them, unless you turn on agent mode. Agent mode auto-runs only allowlisted tools (none by default) and caps the loop with max_agent_depth (default 10). CLI agents such as Claude Code route through the same keys and controls. The broader policy layer is covered under AI governance.
Key takeaways
- Reliability compounds multiplicatively. 95 percent per step is about 60 percent over ten steps, which is the argument for short loops and verification.
- Anthropic measured multi-agent systems at about 15 times the tokens of a chat interaction, so they need parallel, high-value subtasks to justify the cost.
- Scope credentials per tool. Tool permissions are the control that still holds when a prompt injection reaches the model.
- Bound every agent with an iteration cap, a spend cap, and step-level tracing before it reaches production.
Sources and further reading
- NIST AI 100-2e2025 glossary: agent (CSRC)
- Anthropic, Building Effective Agents
- Anthropic, How we built our multi-agent research system
- Anthropic, Effective context engineering for AI agents
- Anthropic, Tool use with Claude
- Anthropic, Tool search tool
- Anthropic, Context windows
- NIST, Agentic AI
- Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models (2022)
- Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning (2023)
- Xu et al., ReWOO: Decoupling Reasoning from Observations for Efficient Augmented Language Models (2023)
- Wu et al., AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation (2023)
- Microsoft, Microsoft Agent Framework and the AutoGen repository, which names Agent Framework as AutoGen's successor
- OpenAI, Reasoning best practices
- Model Context Protocol
- OWASP, LLM06:2025 Excessive Agency
- OWASP, GenAI LLM Top 10 2026
- OpenTelemetry, Semantic conventions for GenAI agent spans
- Bifrost, Virtual keys
- Bifrost, Budget and limits
- Bifrost, MCP gateway
- Bifrost, MCP tool filtering
- Bifrost, MCP tool execution
- Bifrost, Agent mode
- Bifrost, CLI coding agents
- Bifrost, Claude Code + Bifrost
- Bifrost, Request options and headers
- Bifrost, Guardrails (Enterprise)