Jido.AI.Reasoning.GraphOfThoughts.Strategy (Jido AI v2.2.0)

Copy Markdown View Source

Graph-of-Thoughts (GoT) execution strategy for Jido agents.

This strategy implements graph-based reasoning by generating thoughts as nodes, finding connections between them, and aggregating multiple thoughts into conclusions.

Overview

Graph-of-Thoughts extends Tree-of-Thoughts by:

  • Allowing nodes to have multiple parents (graph vs tree)
  • Supporting thought aggregation and synthesis
  • Finding connections between disparate thoughts
  • Enabling more complex reasoning patterns

This approach is effective for problems requiring:

  • Multi-perspective analysis
  • Synthesis of competing ideas
  • Complex causal reasoning
  • Knowledge integration

Architecture

This strategy uses a pure state machine (Jido.AI.Reasoning.GraphOfThoughts.Machine) for all state transitions. The strategy acts as a thin adapter that:

  • Converts instructions to machine messages
  • Converts machine directives to SDK-specific directive structs
  • Manages the machine state within the agent

Configuration

Configure via strategy options when defining your agent:

use Jido.Agent,
  name: "my_got_agent",
  strategy: {
    Jido.AI.Reasoning.GraphOfThoughts.Strategy,
    model: "anthropic:claude-sonnet-4-20250514",
    max_nodes: 20,
    max_depth: 5,
    aggregation_strategy: :synthesis
  }

Options

  • :model (optional) - Model alias or direct model spec, defaults to :fast (resolved via Jido.AI.resolve_model/1)
  • :max_nodes (optional) - Maximum number of nodes, defaults to 20
  • :max_depth (optional) - Maximum graph depth, defaults to 5
  • :aggregation_strategy (optional) - :voting, :weighted, or :synthesis, defaults to :synthesis
  • :generation_prompt (optional) - Custom prompt for thought generation
  • :connection_prompt (optional) - Custom prompt for finding connections
  • :aggregation_prompt (optional) - Custom prompt for aggregation

Signal Routing

This strategy implements signal_routes/1 which AgentServer uses to automatically route these signals to strategy commands:

  • "ai.got.query":got_start
  • "ai.llm.response":got_llm_result
  • "ai.llm.delta":got_llm_partial

State

State is stored under agent.state.__strategy__ with graph structure.

Summary

Functions

Gets the best leaf node from the agent's GoT state.

Gets all edges from the agent's GoT state.

Gets all nodes from the agent's GoT state.

Gets the result from a completed GoT exploration.

Traces the solution path from root to best leaf.

Returns the action atom for handling streaming LLM partial tokens.

Returns the action atom for handling LLM results.

Returns the action atom for handling request rejection events.

Returns the action atom for starting a GoT exploration.

Functions

get_best_node(agent)

Gets the best leaf node from the agent's GoT state.

get_edges(agent)

Gets all edges from the agent's GoT state.

get_nodes(agent)

Gets all nodes from the agent's GoT state.

get_result(agent)

@spec get_result(Jido.Agent.t()) :: term() | nil

Gets the result from a completed GoT exploration.

get_solution_path(agent)

@spec get_solution_path(Jido.Agent.t()) :: [String.t()]

Traces the solution path from root to best leaf.

llm_partial_action()

@spec llm_partial_action() :: :got_llm_partial

Returns the action atom for handling streaming LLM partial tokens.

llm_result_action()

@spec llm_result_action() :: :got_llm_result

Returns the action atom for handling LLM results.

request_error_action()

@spec request_error_action() :: :got_request_error

Returns the action atom for handling request rejection events.

start_action()

@spec start_action() :: :got_start

Returns the action atom for starting a GoT exploration.