adk_runner (erlang_adk v0.2.1)

View Source

adk_runner - Execution orchestrator for ADK 2.0.

The Runner manages the event loop for an agent, handling session retrieval, event recording, tool execution, and streaming responses back to the caller.

Summary

Functions

Create a new Runner with required services.

Create a new Runner with optional services (memory_svc, artifact_svc).

Resume a paused workflow (Human-in-the-Loop) with a human-provided result.

Execute the agent synchronously, returning the final response text. This blocks until the entire invocation is complete.

Execute the agent asynchronously, returning a process ID that streams events. The returned PID will send '{adk_event, StreamPid, Event}' and '{adk_done, StreamPid}' messages.

Types

runner/0

-type runner() ::
          #runner{agent :: pid() | module(),
                  app_name :: binary(),
                  session_svc :: module(),
                  memory_svc :: module() | undefined,
                  artifact_svc :: module() | undefined}.

Functions

new(Agent, AppName, SessionSvc)

-spec new(Agent :: pid() | module(), AppName :: binary(), SessionSvc :: module()) -> runner().

Create a new Runner with required services.

new(Agent, AppName, SessionSvc, Opts)

-spec new(Agent :: pid() | module(), AppName :: binary(), SessionSvc :: module(), Opts :: map()) ->
             runner().

Create a new Runner with optional services (memory_svc, artifact_svc).

resume(Runner, UserId, SessionId, ToolResponse)

-spec resume(Runner :: runner(), UserId :: binary(), SessionId :: binary(), ToolResponse :: term()) ->
                {ok, pid()} | {error, term()}.

Resume a paused workflow (Human-in-the-Loop) with a human-provided result.

run(Runner, UserId, SessionId, Message)

-spec run(Runner :: runner(), UserId :: binary(), SessionId :: binary(), Message :: term()) ->
             {ok, binary()} | {error, term()}.

Execute the agent synchronously, returning the final response text. This blocks until the entire invocation is complete.

run_async(Runner, UserId, SessionId, Message)

-spec run_async(Runner :: runner(), UserId :: binary(), SessionId :: binary(), Message :: term()) ->
                   {ok, pid()}.

Execute the agent asynchronously, returning a process ID that streams events. The returned PID will send '{adk_event, StreamPid, Event}' and '{adk_done, StreamPid}' messages.