ADK.Phoenix.Channel (ADK v0.0.1-alpha.1)

Copy Markdown View Source

A use-able module that adds ADK agent interaction to a Phoenix Channel.

Requires Phoenix to be available at compile time. If Phoenix is not loaded, the module defines the macros but they will raise at compile time when used.

Usage

In your Phoenix application:

defmodule MyAppWeb.AgentChannel do
  use MyAppWeb, :channel
  use ADK.Phoenix.Channel, agent: &MyApp.Agents.assistant/0

  # Optional: override to customize session/user resolution
  def adk_user_id(socket), do: socket.assigns.user_id
  def adk_session_id(socket), do: socket.assigns.session_id
end

This adds handlers for:

  • "agent:run" — synchronous run, replies with all events
  • "agent:stream" — async run, pushes events as they arrive