ADK.Flow (adk_ex v1.1.0)

Copy Markdown View Source

Core execution engine for LLM agents.

Implements the request->model->response->tool loop. Each iteration:

  1. Build an LlmRequest via request processors
  2. Run before_model callbacks (may short-circuit)
  3. Call the model's generate_content
  4. Run after_model callbacks
  5. If the response contains function calls, execute tools
  6. Yield events; loop if tool responses were generated

Summary

Functions

Runs the flow loop, returning a stream of events.

Types

after_model_callback()

after_tool_callback()

@type after_tool_callback() :: (ADK.Tool.Context.t(), struct(), map(), map() ->
                            {map() | nil, ADK.Tool.Context.t()})

before_model_callback()

before_tool_callback()

@type before_tool_callback() :: (ADK.Tool.Context.t(), struct(), map() ->
                             {map() | nil, ADK.Tool.Context.t()})

request_processor()

@type request_processor() :: (ADK.Agent.InvocationContext.t(),
                        ADK.Model.LlmRequest.t(),
                        map() ->
                          {:ok, ADK.Model.LlmRequest.t()})

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

run(flow, ctx)

Runs the flow loop, returning a stream of events.