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

Copy Markdown View Source

Chain-of-Thought strategy delegated to an internal per-parent worker agent.

The parent strategy remains the orchestration boundary while a lazily spawned child worker (:cot_worker) owns runtime execution and streaming.

Delegation Model

  1. Parent receives "ai.cot.query" and prepares worker payload.
  2. Parent lazily spawns internal worker on first request (if needed).
  3. Parent emits "ai.cot.worker.start" to worker.
  4. Worker performs one CoT LLM turn and emits "ai.cot.worker.event" envelopes.
  5. Parent applies worker events to CoT state and preserves external API.

Request Lifecycle Contract

  • Runtime worker events are normalized into lifecycle transitions: request_started, request_completed, request_failed, request_cancelled.
  • LLM stream events (llm_started, llm_delta, llm_completed) update snapshot fields and emit canonical lifecycle signals (ai.llm.delta, ai.llm.response, ai.usage).
  • Concurrency policy defaults to request_policy: :reject; concurrent requests emit ai.request.error with reason: :busy.
  • Request traces are retained in bounded in-memory state (cap: 2000 events per request, then marked truncated).

Summary

Functions

Returns the conclusion from the agent's current state.

Returns the raw LLM response from the agent's current state.

Returns the extracted reasoning steps from the agent's current state.

Returns the legacy action atom for handling streaming LLM partial tokens (no-op in delegated mode).

Returns the legacy action atom for handling LLM results (no-op in delegated mode).

Returns the action atom for handling request rejection events.

Returns the action atom for starting a CoT reasoning session.

Types

config()

@type config() :: %{
  system_prompt: String.t(),
  model: String.t(),
  request_policy: :reject,
  llm_timeout_ms: pos_integer() | nil,
  runtime_task_supervisor: pid() | atom() | nil,
  observability: map(),
  runtime_adapter: true
}

Functions

get_conclusion(agent)

@spec get_conclusion(Jido.Agent.t()) :: String.t() | nil

Returns the conclusion from the agent's current state.

get_raw_response(agent)

@spec get_raw_response(Jido.Agent.t()) :: String.t() | nil

Returns the raw LLM response from the agent's current state.

get_steps(agent)

Returns the extracted reasoning steps from the agent's current state.

llm_partial_action()

@spec llm_partial_action() :: :cot_llm_partial

Returns the legacy action atom for handling streaming LLM partial tokens (no-op in delegated mode).

llm_result_action()

@spec llm_result_action() :: :cot_llm_result

Returns the legacy action atom for handling LLM results (no-op in delegated mode).

request_error_action()

@spec request_error_action() :: :cot_request_error

Returns the action atom for handling request rejection events.

start_action()

@spec start_action() :: :cot_start

Returns the action atom for starting a CoT reasoning session.