Work in a bounded loop. On each turn: call the model, execute any requested tool actions, record each observation, then ask the termination policy whether to continue. Return exactly one terminal result, or stop with a typed exhaustion error.Minimal linear loop
Alternate model turns and action execution.
agent_turn_executionRECORD STATUSCandidate · v0.1.0UML class view
The proposed contract drawn as participant roles, received calls, and numbered dependencies.
Object interactions
The same roles and calls as a class collaboration and a numbered message sequence.
Pointcut
Where the mechanism applies. All four dimensions belong to the proposed match, not just its vocabulary.
- Context
- A harness executes an agent with at least one model or action turn.
- Trigger
- A model response requests tools or another turn.
- Structure
- Ordered turn/result records and an explicit repeat-or-terminate decision.
- Effect
- Every turn yields a terminal result, a tool action, or another legal turn.
Protected contract
The obligation that clients, operators, and auditors should be able to rely on.
- Requires
- Model output, action dispatch, and a termination predicate are available.
- Ensures
- Actions are correlated with their turn and a terminal outcome is returned.
- Invariant
- Each completed turn has one recorded decision and no unexplained action.
- Violation
- Premature stop, malformed action, or repeated retry must terminate or surface an error.
Negative control
A one-shot model call with no action cycle does not satisfy the pointcut.
Variation & lifecycle
The hot spot is admitted only where the protected semantics survive.
Permitted variation
Prompt, tool set, stopping predicate, and turn result encoding.
Test obligation
Test normal completion, immediate malformed output, and retry exhaustion.
Evolution question
Has the loop moved from ad hoc control to a typed runner or state machine?
Prompt + code design
An illustrative prompt and a small design sketch for the proposed contract. Names and APIs are invented; this is not a repository excerpt.
def run(task, model, tools, policy):
history = [user_message(task)]
for turn in range(policy.max_turns):
reply = model.respond(history)
history.append(reply.as_message())
for action in reply.tool_calls:
observation = tools.execute(action, turn=turn)
history.append(observation.as_message())
decision = policy.decide(history, turn)
if decision.stop:
return decision.result
raise LoopExhausted(turns=policy.max_turns)Illustrative design sketch. The runner, not the prompt, owns turn identity and the terminal decision. This example is a teaching aid, not implementation evidence or a conformance claim.
Detection & matching
The frozen rule that retrieves this record, the canonical source exemplar, and the control that should stay unmatched.
- Join point
agent_turn_execution- Source locator
- Barbaste et al., §6.2, p. 14 (Mini-SWE-Agent, “Minimal Linear Loop”); source label
- Lexical cue
(?i)\bwhile\s+(?:true|not\s+done)|\bmax_(?:turns|steps|iterations)\b|\brun_(?:loop|until)\bFrozen expression, v0.1.0. A match is a retrieval cue, not a confirmed implementation.- Aliases
- None
- Canonical exemplar
- openai/openai-agents-python
src/agents/run_internal/run_loop.py:987Support: tests/test_agent_runner.py:1 - Negative control
- A one-shot model call with no action cycle does not satisfy the pointcut.
Scope-anchored review. pohe-agent analyze <repo> --pattern P01 anchors the cue to its enclosing declaration and checks a separate operational signature for all four pointcut dimensions. Missing roles and negative-control risks remain visible; a structural match is not E2/E3. Calibration report ↗
Repository files
Up to five public files retrieved by the frozen cue and pinned to the audited commit. A match is a place to inspect, not a confirmed implementation.
src/agents/run_internal/run_loop.py:987CANONICAL SOURCE02aaif-goose/goosecrates/goose/examples/agent.rs:61RETRIEVAL CUE03affaan-m/ECCskills/skill-comply/scripts/grader.py:94RETRIEVAL CUE04agno-agi/agnolibs/agno/agno/company/manager.py:328RETRIEVAL CUE05Aider-AI/aideraider/coders/base_coder.py:882RETRIEVAL CUEEvidence & provenance
Each layer answers a different question. Do not substitute retrieval for review.
Source-located exemplar
A concrete source anchor is available for this proposed record. It is one exemplar, not evidence that all repositories—or every contract field—conform.
Review boundary: this candidate and its specification come from an AI-assisted study. Independent human validation remains open.
97.2% of repository families in the frozen panel have at least one current cue, historical cue, or canonical source layer. This is not confirmed prevalence.
Current lexical-cue repositories: 39 / 4186bd29878b30src/agents/run_internal/run_loop.py:987tests/test_agent_runner.py:1Explicit agent turn/tool streaming loop.
Exploratory retrieval cue Regex / v0.1.0
(?i)\bwhile\s+(?:true|not\s+done)|\bmax_(?:turns|steps|iterations)\b|\brun_(?:loop|until)\bThis expression is a discovery instrument only. A match is a retrieval cue—not a confirmed implementation, pointcut match, or contract proof.