Jido.Composer.Node.AgentNode (Jido Composer v0.4.0)

Copy Markdown View Source

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.

Summary

Types

mode()

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

t()

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

Functions

new(agent_module, config \\ [])

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

timeout(agent_node)

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