ADK.Agent.CallbackContext (adk_ex v1.1.0)

Copy Markdown View Source

Context available to before/after agent callbacks.

Wraps an InvocationContext and provides an actions field for callbacks to record side effects (state changes, transfers, etc.).

Summary

Functions

Returns the agent name from the underlying invocation context.

Returns the app name.

Gets a value from session state, checking the actions state_delta first.

Returns the invocation ID.

Creates a new callback context from an invocation context.

Searches memory for entries matching the query.

Returns the session ID.

Sets a value in the actions state_delta.

Returns the user ID.

Types

t()

@type t() :: %ADK.Agent.CallbackContext{
  actions: ADK.Event.Actions.t(),
  invocation_context: ADK.Agent.InvocationContext.t()
}

Functions

agent_name(callback_context)

@spec agent_name(t()) :: String.t() | nil

Returns the agent name from the underlying invocation context.

app_name(callback_context)

@spec app_name(t()) :: String.t() | nil

Returns the app name.

get_state(callback_context, key)

@spec get_state(t(), String.t()) :: any()

Gets a value from session state, checking the actions state_delta first.

invocation_id(callback_context)

@spec invocation_id(t()) :: String.t() | nil

Returns the invocation ID.

new(ctx)

@spec new(ADK.Agent.InvocationContext.t()) :: t()

Creates a new callback context from an invocation context.

search_memory(callback_context, query)

@spec search_memory(t(), String.t()) :: {:ok, [ADK.Memory.Entry.t()]}

Searches memory for entries matching the query.

Returns {:ok, [Entry.t()]} or {:ok, []} if no memory service is configured.

session_id(callback_context)

@spec session_id(t()) :: String.t() | nil

Returns the session ID.

set_state(cb_ctx, key, value)

@spec set_state(t(), String.t(), any()) :: t()

Sets a value in the actions state_delta.

user_id(callback_context)

@spec user_id(t()) :: String.t() | nil

Returns the user ID.