# `Jido.AI.Reasoning.GraphOfThoughts.Strategy`
[🔗](https://github.com/agentjido/jido_ai/blob/v2.4.0/lib/jido_ai/reasoning/graph_of_thoughts/strategy.ex#L1)

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.

# `get_best_node`

```elixir
@spec get_best_node(Jido.Agent.t()) ::
  Jido.AI.Reasoning.GraphOfThoughts.Machine.thought_node() | nil
```

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

# `get_edges`

```elixir
@spec get_edges(Jido.Agent.t()) :: [Jido.AI.Reasoning.GraphOfThoughts.Machine.edge()]
```

Gets all edges from the agent's GoT state.

# `get_nodes`

```elixir
@spec get_nodes(Jido.Agent.t()) :: [
  Jido.AI.Reasoning.GraphOfThoughts.Machine.thought_node()
]
```

Gets all nodes from the agent's GoT state.

# `get_result`

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

Gets the result from a completed GoT exploration.

# `get_solution_path`

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

Traces the solution path from root to best leaf.

# `llm_partial_action`

```elixir
@spec llm_partial_action() :: :got_llm_partial
```

Returns the action atom for handling streaming LLM partial tokens.

# `llm_result_action`

```elixir
@spec llm_result_action() :: :got_llm_result
```

Returns the action atom for handling LLM results.

# `request_error_action`

```elixir
@spec request_error_action() :: :got_request_error
```

Returns the action atom for handling request rejection events.

# `start_action`

```elixir
@spec start_action() :: :got_start
```

Returns the action atom for starting a GoT exploration.

---

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