adk_runner (erlang_adk v0.2.5)

View Source

adk_runner - Event and session execution orchestrator.

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 and run_timeout.

Resume a paused workflow with a human-provided result. The original invocation ID, tool name, and thought signature are retained.

Execute the agent synchronously, returning only after a terminal message.

Execute the agent asynchronously. The worker emits adk_event messages and exactly one terminal adk_done, adk_paused, or adk_error message.

Types

runner/0

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

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 and run_timeout.

resume(Runner, UserId, SessionId, ToolResponse)

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

Resume a paused workflow with a human-provided result. The original invocation ID, tool name, and thought signature are retained.

run(Runner, UserId, SessionId, Message)

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

Execute the agent synchronously, returning only after a terminal message.

run_async(Runner, UserId, SessionId, Message)

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

Execute the agent asynchronously. The worker emits adk_event messages and exactly one terminal adk_done, adk_paused, or adk_error message.