Agentic Tool-Use Loop
An agent plans, calls tools, observes results, and iterates to a goal.
AdvancedAI / ML
Given a goal, the agent runtime asks the model to choose a next action, executes it against a tool (an API, a database, a search), feeds the observation back, and repeats until the model decides the goal is met or a step limit is hit.
When to use it
- The task requires multiple dependent steps that can't be resolved in a single prompt
- The model needs live access to systems (search, internal APIs) beyond its training data
Trade-offs
- Runaway loops or wrong tool calls need explicit step/cost limits and guardrails
- Non-deterministic paths make agent behaviour harder to test than a fixed pipeline
Components used
Single-Page AppAgent RuntimeLLM / Model EndpointManaged App ServiceSearch Index
How it works
- The model receives a goal plus a schema describing the tools it may call. Instead of answering, it emits a structured tool call.
- The runtime executes the tool, appends the result to the conversation, and calls the model again. This repeats until the model emits a final answer or a step budget is exhausted.
- All state lives in the growing message history, so the loop is only as reliable as your ability to keep that history coherent and bounded.
Used in the wild
- Coding agents that read files, run tests and iterate on failures.
- Operations copilots that query dashboards, correlate alerts and open an incident ticket.
- Research tasks that need several dependent searches where the second query depends on the first result.
Good to know
- The pattern was popularised by the ReAct paper (Reason + Act, 2022), which showed that interleaving reasoning traces with tool calls beat doing either alone.
- Always cap the iteration count. Without a budget, agents reliably discover infinite loops — typically calling the same failing tool forever because the error message never changes.
Related patterns
Retrieval-Augmented Generation (RAG)
Ground an LLM's answers in retrieved, up-to-date, private documents.
Vector Search + Rerank
Cheaply retrieve a broad candidate set, then precisely re-rank the top results.
Model Serving with A/B Testing
Route inference traffic across model versions to compare live performance.
Fine-Tuning Pipeline
Curate a training set, fine-tune a base model, and register the result.