The iteration engine of a turn.
run-iteration sends one provider request and runs the code blocks it
returns. iteration-loop repeats that until the model answers, recovering
from empty replies, stream failures, exhausted output budgets, rejected
credentials and context overflow within their retry budgets.
The iteration engine of a turn. `run-iteration` sends one provider request and runs the code blocks it returns. `iteration-loop` repeats that until the model answers, recovering from empty replies, stream failures, exhausted output budgets, rejected credentials and context overflow within their retry budgets.
(final-answer-gate-error environment iteration blocks)(final-answer-gate-error environment iteration blocks answer-value)(final-answer-gate-error environment
iteration
blocks
answer-value
active-extensions)(final-answer-gate-error environment
iteration
blocks
answer-value
active-extensions
extra-ctx)Dispatch :turn.answer/validate extension hooks against the
candidate answer. Returns nil when every hook accepts,
otherwise a single string surfaced as the rejected answer's
validation error.
A final answer is plain prose with no tool calls, so it inherently
never shares an iteration with extension/tool calls: the model uses
one iteration to observe tool output, then a later iteration replies
with the answer. Extensions that need an additional veto (e.g.
user-facing safety / format gates) still get their
:turn.answer/validate hook fired here.
active-extensions is passed by the turn loop so activation is
computed once per turn; direct callers may omit it and provide
:extensions on the environment.
Dispatch `:turn.answer/validate` extension hooks against the candidate answer. Returns nil when every hook accepts, otherwise a single string surfaced as the rejected answer's validation error. A final answer is plain prose with no tool calls, so it inherently never shares an iteration with extension/tool calls: the model uses one iteration to observe tool output, then a later iteration replies with the answer. Extensions that need an additional veto (e.g. user-facing safety / format gates) still get their `:turn.answer/validate` hook fired here. `active-extensions` is passed by the turn loop so activation is computed once per turn; direct callers may omit it and provide `:extensions` on the environment.
(iteration-loop environment user-request opts)Run the core loop with disk-backed trace history, released on every exit path.
Run the core loop with disk-backed trace history, released on every exit path.
(run-iteration environment
messages
&
[{:keys [routing iteration reasoning-level reasoning-effort
resolved-model on-chunk extra-body llm-headers
active-extensions answer-validation-context
request-context on-response message-token-counter
input-token-estimator]}])Runs a single RLM iteration: ask! -> check final -> execute code. Returns map with :thinking :blocks :final-result :api-usage etc.
Runs a single RLM iteration: ask! -> check final -> execute code. Returns map with :thinking :blocks :final-result :api-usage etc.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |