# `Jido.Composer.Node.AgentNode`
[🔗](https://github.com/lostbean/jido_composer/blob/main/lib/jido/composer/node/agent_node.ex#L1)

Wraps a `Jido.Agent` module as a Node.

AgentNode carries per-instance configuration for how the agent should be
spawned and communicated with. It supports three communication modes:

- `:sync` (default) — spawn agent, send context as signal, await result
- `:async` — spawn agent, return immediately with `:pending` outcome
- `:streaming` — spawn agent, subscribe to state transitions at specified states

AgentNode delegates metadata (name, description, schema) to the wrapped
agent module. Scoping of results is the responsibility of the composition
layer (Machine/Strategy), not the node.

## Jido.AI Agent Support

AgentNode also supports `Jido.AI.Agent` modules (e.g. `use Jido.AI.Agent`).
These are detected automatically — they export `ask_sync/3` but not
`run_sync/2` or `query_sync/3`. See `Jido.Composer.Node.ai_agent_module?/1`.

In sync mode, `run/3` spawns a temporary `AgentServer`, sends the query
via `ask_sync/3`, and stops the process after receiving the result.

Tool spec generation adapts for AI agents: instead of exposing the agent's
internal state schema, `to_tool_spec/1` returns a `{"query": "string"}` schema
so the agent appears as a clean tool in orchestrator contexts.

# `mode`

```elixir
@type mode() :: :sync | :async | :streaming
```

# `t`

```elixir
@type t() :: %Jido.Composer.Node.AgentNode{
  agent_module: module(),
  mode: mode(),
  on_state: [atom()] | nil,
  opts: keyword(),
  signal_type: String.t() | nil
}
```

# `new`

```elixir
@spec new(
  module(),
  keyword()
) :: {:ok, t()} | {:error, term()}
```

# `timeout`

```elixir
@spec timeout(t()) :: pos_integer()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
