Agentscore
The agent loop (ReAct)
Model decides → calls a tool → reads the result → decides again, until done.
What it is and why it exists
An agent is an LLM in a loop with tools: each turn it either calls tools or answers. ReAct interleaves reasoning and acting so each observation informs the next step. The model chooses the path; your code runs tools, enforces limits and decides when to stop.
Quick prototype
while True: call model; if tool calls, run them and append results; else return the text.
In production, at scale
The same loop with step, token, time and cost budgets, validated tool arguments, a permission layer, retries and timeouts per tool, loop detection, tracing of every step, checkpoints for long runs and human approval for risky actions.
Vendors and tools
| OpenAI Agents SDK | Agent loop, handoffs, guardrails, tracing |
|---|---|
| Claude Agent SDK | The harness behind Claude Code as a library |
| LangGraph | Agent loops as explicit graphs with state and checkpoints |
| Google ADK / Pydantic AI / smolagents | Other agent frameworks |
On AWS: Bedrock Agents (managed loop with action groups); Bedrock AgentCore Runtime for hosting your own agent code; Strands Agents SDK.
How it fails
- Infinite loops repeating the same call
- Wandering off-task after a confusing tool result
- Costs that vary 20× between runs
What the interviewer asks next
Write the agent loop in ten lines.
messages = [system, user]; for step in range(MAX): r = model(messages, tools); messages.append(r); if not r.tool_calls: return r.text; for c in r.tool_calls: messages.append(tool_result(c.id, run(c))); raise BudgetExceeded.
When should something not be an agent?
When you can draw the path in advance. A fixed workflow is cheaper, faster, testable and predictable; use an agent only where the steps genuinely depend on what is found.