Core execution engine for LLM agents.
Implements the request->model->response->tool loop. Each iteration:
- Build an LlmRequest via request processors
- Run before_model callbacks (may short-circuit)
- Call the model's generate_content
- Run after_model callbacks
- If the response contains function calls, execute tools
- Yield events; loop if tool responses were generated
Summary
Functions
Runs the flow loop, returning a stream of events.
Types
@type after_model_callback() :: (ADK.Agent.CallbackContext.t(), ADK.Model.LlmResponse.t() -> {ADK.Model.LlmResponse.t() | nil, ADK.Agent.CallbackContext.t()})
@type after_tool_callback() :: (ADK.Tool.Context.t(), struct(), map(), map() -> {map() | nil, ADK.Tool.Context.t()})
@type before_model_callback() :: (ADK.Agent.CallbackContext.t(), ADK.Model.LlmRequest.t() -> {ADK.Model.LlmResponse.t() | nil, ADK.Agent.CallbackContext.t()})
@type before_tool_callback() :: (ADK.Tool.Context.t(), struct(), map() -> {map() | nil, ADK.Tool.Context.t()})
@type request_processor() :: (ADK.Agent.InvocationContext.t(), ADK.Model.LlmRequest.t(), map() -> {:ok, ADK.Model.LlmRequest.t()})
@type t() :: %ADK.Flow{ after_model_callbacks: [after_model_callback()], after_tool_callbacks: [after_tool_callback()], before_model_callbacks: [before_model_callback()], before_tool_callbacks: [before_tool_callback()], model: struct() | nil, on_model_error_callbacks: [term()], on_tool_error_callbacks: [term()], request_processors: [request_processor()], response_processors: [term()], tools: [struct()], toolsets: [struct()] }
Functions
@spec run(t(), ADK.Agent.InvocationContext.t()) :: Enumerable.t()
Runs the flow loop, returning a stream of events.