ai.Agent
The default runner. A spec-mode LLM function's direct call runs `Agent.new(client = client).run(Fn@spec(...)).value`; construct it yourself to set the other fields (`$` call-site parameters are a future phase).
Signature
class ai.AgentThe default runner. A spec-mode LLM function's direct call runs
Agent.new(client = client).run(Fn@spec(...)).value; construct it
yourself to set the other fields ($ call-site parameters are a future
phase).
The class itself is not generic: none of its configuration involves the
output type. Out lives on run, where it is inferred from the spec
argument, so no call site needs to name it.
Source:<builtin>/ai/runner.bamlbytes 1178–18897
Fields
max_steps
intschema_attempts
intclient
ai.Client | nulltool_errors
on_event
((ai.events.Event) -> void throws never) | nullStatic methods
new
<__effect_param_0>(Instance methods
_attempt_turn
<Out>((internal) One accepted model turn, with the within-turn repair loop: when a
Complete turn's candidate does not parse, commit the failed turn and a
correction request as ordinary events and invoke again, under a fixed
attempt budget. Everything that happened is on the record; a repair
attempt does not consume a step. Token usage of every attempt is
added to total.
(internal) Emit any events appended since seen to on_event; returns the new count.
(internal) Does this turn carry content a media-shaped Out can be built from?
Mirrors the Ok(None) condition of sys_llm's
parse_llm_output_for_target: nothing to build from means fall back to
the ordinary text parse. Always false when Out holds no media.
_media_value
<Out>((internal) Build a media-shaped Out from the turn's content blocks. Only called
when _has_media_output holds; the shape-specific errors below are the
ported sys_llm messages, thrown after the turn is already on the record.
_parses
<Out>(_run_one_tool
((internal) Execute one call: validate, dispatch, append the correlated result. A Raise-mode failure throws ToolFailedError after ToolFailed lands.
_validated_schema_attempts
(self) -> int throws baml.errors.InvalidArgumentImplementations
ai.Runner for ai.Agent
Error = baml.errors.InvalidArgument | baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.FailureInstance methods
run
<Out>(Source:<builtin>/ai/runner.bamlbytes 13139–18895