Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ config :a2ui, component_modules: %{"StatusBadge" => MyApp.A2UI.StatusBadge}

Set `use_default_components: false` to replace all built-in components with your own. See the `A2UI.ComponentRenderer` and `A2UI.Components.Renderer` hexdocs for the full assigns contract, available helpers, and configuration details.

## A2A Configuration

The A2A server adapter waits for the wrapped agent to acknowledge synchronization and for
buffered A2UI responses to be drained. Configure the timeout for each wait in milliseconds:

```elixir
# config/config.exs
config :a2ui, :a2a_sync_timeout, 5_000
```

The default is `5_000` milliseconds. This is a compile-time setting, so changes require
recompiling the application. If synchronization times out, processing continues; if draining
times out, the response contains no buffered A2UI parts.

## Installation

Add `a2ui` to your list of dependencies in `mix.exs`:
Expand Down
19 changes: 17 additions & 2 deletions lib/a2ui/a2a.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ if Code.ensure_loaded?(A2A.Agent) do
- All other options (`:name`, `:description`, `:version`, `:skills`)
are forwarded to `use A2A.Agent`.

## Configuration

Configure the timeout for each A2A synchronization acknowledgement and buffered response
drain in milliseconds:

config :a2ui, :a2a_sync_timeout, 5_000

The default is `5_000` milliseconds. This is a compile-time setting, so changes require
recompiling the application. If synchronization times out, processing continues; if draining
times out, the response contains no buffered A2UI parts.

## Protocol Mapping

- First A2A message in a task triggers `handle_connect` on the A2UI agent
Expand All @@ -42,6 +53,10 @@ if Code.ensure_loaded?(A2A.Agent) do
alias A2UI.Connection
alias A2UI.Protocol.Message, as: Msg

# Timeout (ms) for the A2A sync/drain handshake with the A2UI agent.
# Overridable per-application: `config :a2ui, a2a_sync_timeout: <ms>`.
@a2a_sync_timeout Application.compile_env(:a2ui, :a2a_sync_timeout, 5_000)

@doc false
defmacro __using__(opts) do
agent = Keyword.fetch!(opts, :agent)
Expand Down Expand Up @@ -152,7 +167,7 @@ if Code.ensure_loaded?(A2A.Agent) do
receive do
{:a2ui_sync_ack, ^ref} -> :ok
after
5_000 -> :timeout
@a2a_sync_timeout -> :timeout
end
end

Expand All @@ -166,7 +181,7 @@ if Code.ensure_loaded?(A2A.Agent) do
A2A.Part.Data.new(Msg.to_map(msg))
end)
after
5_000 -> []
@a2a_sync_timeout -> []
end
end

Expand Down