Principle:ARCANGEL0 EVA Agent Turn Execution
| Knowledge Sources | |
|---|---|
| Domains | Agentic_Systems, LLM, Security_Automation |
| Last Updated | 2026-10-29 14:00 GMT |
Overview
Execution pattern in which a language model drives an iterative cycle of reasoning, tool invocation, and observation within a bounded turn budget, with mode-gated safety enforcement.
Description
The agent turn loop is the core execution model for autonomous AI agents. Instead of a single prompt-response exchange, the model enters a multi-step loop: it receives a task, reasons about what to do, selects and invokes a tool, observes the result, and repeats until the task is complete or a resource limit is reached. Each iteration produces a tool call that the host environment executes, feeding the result back as a new observation.
This pattern addresses a fundamental limitation of single-shot prompting: complex tasks require intermediate action and feedback that a single response cannot capture. By interleaving reasoning and action (the ReAct paradigm), the agent can adapt its plan based on real-world results, recover from errors, and build up evidence over multiple steps.
Key design constraints in this implementation:
- Turn budget: A maximum of 48 tool calls per turn prevents runaway loops.
- Mode enforcement: Recon (passive), Guided (checkpoint after each action), AutoPwn (autonomous within scope).
- Interrupt handling: The operator can interrupt at any point; in-flight tool calls are cleaned up.
- Retry logic: Transient provider errors (429, 5xx) trigger up to 10 retries with backoff.
Usage
Use this principle when designing an autonomous agent that:
- Performs multi-step tasks requiring tool use (shell commands, searches, API calls).
- Needs safety boundaries on how many actions it can take autonomously.
- Must allow operator intervention and mode-based escalation.
- Should recover gracefully from transient infrastructure failures.
Theoretical Basis
The agent turn loop is an instance of the ReAct (Reasoning + Acting) pattern:
# Abstract algorithm (NOT real implementation)
while not done and tool_calls < max_budget:
if operator_requested_interrupt():
break
response = model.reason(system_prompt, history, available_tools)
if not response.tool_calls:
done = True
continue
for invocation in response.tool_calls:
if mode_requires_approval(invocation) and not operator_approves(invocation):
result = "declined"
else:
result = execute_tool(invocation)
history.append(result)
The loop maintains a conversation history that grows with each tool call and result. The system prompt is augmented with operator messages, validated access context, and mode-specific directives on each iteration. When the model returns no tool calls, the turn ends naturally; when the budget is exhausted, the model is forced to summarize.
Practical Guide
- Set a realistic tool-call budget — too low starves complex tasks, too high risks runaway.
- Inject dynamic context (Intel, operator messages) into the system prompt on each iteration, not just the first.
- Use a finally block to repair conversation history even when the turn is interrupted.
- Distinguish transient errors (retry) from permanent errors (surface to the model).
- Track failed calls to prevent the model from retrying identical failed commands.
Related Pages
Implemented By
- Implementation:ARCANGEL0_EVA_run_agent_turn
- Implementation:ARCANGEL0_EVA_AgentToolHost
- Implementation:ARCANGEL0_EVA_request_agent_turn
- Implementation:ARCANGEL0_EVA_finish_interrupted_tools
- Implementation:ARCANGEL0_EVA_intel_context