Jido.AI.GoTAgent (Jido AI v2.2.0)

Copy Markdown View Source

Base macro for Graph-of-Thoughts-powered agents.

Wraps use Jido.Agent with Jido.AI.Reasoning.GraphOfThoughts.Strategy wired in, plus standard state fields and helper functions.

Usage

defmodule MyApp.ResearchSynthesizer do
  use Jido.AI.GoTAgent,
    name: "research_synthesizer",
    description: "Synthesizes research from multiple perspectives",
    max_nodes: 30,
    max_depth: 6,
    aggregation_strategy: :synthesis
end

Options

  • :name (required) - Agent name
  • :description - Agent description (default: "GoT agent #{name}")
  • :model - Model alias or direct model spec (default: :fast, resolved via Jido.AI.resolve_model/1)
  • :max_nodes - Maximum number of nodes in the graph (default: 20)
  • :max_depth - Maximum depth of the graph (default: 5)
  • :aggregation_strategy - :voting, :weighted, or :synthesis (default: :synthesis)
  • :generation_prompt - Custom prompt for thought generation
  • :connection_prompt - Custom prompt for finding connections
  • :aggregation_prompt - Custom prompt for aggregation
  • :skills - Additional skills to attach to the agent (TaskSupervisorSkill is auto-included)

Generated Functions

  • explore/2,3 - Async: sends prompt, returns {:ok, %Request{}} for later awaiting
  • await/1,2 - Awaits a specific request's completion
  • explore_sync/2,3 - Sync convenience: sends prompt and waits for result
  • strategy_opts/0 - Returns the strategy options for CLI access
  • on_before_cmd/2 - Captures request in state before processing
  • on_after_cmd/3 - Updates request result when done

Request Tracking

Each explore/2 call returns a Request struct that can be awaited:

{:ok, request} = MyAgent.explore(pid, "Analyze the impact of AI on healthcare")
{:ok, result} = MyAgent.await(request, timeout: 30_000)

Or use the synchronous convenience wrapper:

{:ok, result} = MyAgent.explore_sync(pid, "Analyze the impact of AI on healthcare")

State Fields

The agent state includes:

  • :model - The LLM model being used
  • :requests - Map of request_id => request state (for concurrent tracking)
  • :last_request_id - ID of the most recent request
  • :last_prompt - The most recent prompt (backward compat)
  • :last_result - The final result from the last completed exploration (backward compat)
  • :completed - Boolean indicating if the last exploration is complete (backward compat)

Task Supervisor

Each agent instance gets its own Task.Supervisor automatically started via the Jido.AI.Plugins.TaskSupervisor. This supervisor is used for:

  • LLM streaming operations
  • Other async operations within the agent's lifecycle

Example

{:ok, pid} = Jido.AgentServer.start(agent: MyApp.ResearchSynthesizer)

# Async pattern (preferred for concurrent requests)
{:ok, request} = MyApp.ResearchSynthesizer.explore(pid, "Analyze the impact of AI on healthcare")
{:ok, result} = MyApp.ResearchSynthesizer.await(request)

# Sync pattern (convenience for simple cases)
{:ok, result} = MyApp.ResearchSynthesizer.explore_sync(pid, "Analyze the impact of AI on healthcare")

Aggregation Strategies

  • :voting - Selects the most common conclusion among thoughts
  • :weighted - Weights thoughts by their scores when aggregating
  • :synthesis - Synthesizes all thoughts into a coherent conclusion (default)