Jido.Composer.Orchestrator.Obs (Jido Composer v0.6.0)

Copy Markdown View Source

Observability state and span lifecycle for orchestrator strategies.

Encapsulates all OTel span management, token accumulation, and LLM message normalization that was previously scattered across Strategy. Strategy stores a single _obs: %Obs{} | nil field instead of five separate _obs_* fields.

Summary

Functions

Extracts the agent name for obs span metadata.

Builds observability measurements from an LLM result instruction params. Extracts token usage, finish reason, and output messages from the ReqLLM response structures.

Extracts input messages from a ReqLLM conversation context, normalizing them into plain maps suitable for OTel span attributes.

Returns a fresh Obs struct.

Summarizes the conversation state for span metadata.

Types

t()

@type t() :: %Jido.Composer.Orchestrator.Obs{
  agent_span: term() | nil,
  cumulative_tokens: %{
    prompt: non_neg_integer(),
    completion: non_neg_integer(),
    total: non_neg_integer()
  },
  iteration_span: term() | nil,
  llm_span: term() | nil,
  tool_spans: %{optional(String.t()) => term()}
}

Functions

accumulate_tokens(obs, measurements)

@spec accumulate_tokens(t(), map()) :: t()

agent_name(agent)

@spec agent_name(map()) :: String.t()

Extracts the agent name for obs span metadata.

build_llm_measurements(params)

@spec build_llm_measurements(map()) :: map()

Builds observability measurements from an LLM result instruction params. Extracts token usage, finish reason, and output messages from the ReqLLM response structures.

extract_input_messages(arg1)

@spec extract_input_messages(term()) :: [map()] | nil

Extracts input messages from a ReqLLM conversation context, normalizing them into plain maps suitable for OTel span attributes.

finish_agent_span(obs, state, extra \\ %{})

@spec finish_agent_span(t(), map(), map()) :: t()

finish_iteration_span(obs, measurements)

@spec finish_iteration_span(t(), map()) :: t()

finish_llm_span(obs, measurements)

@spec finish_llm_span(t(), map()) :: t()

finish_tool_span(obs, call_id, measurements)

@spec finish_tool_span(t(), String.t(), map()) :: t()

new()

@spec new() :: t()

Returns a fresh Obs struct.

start_agent_span(obs, metadata)

@spec start_agent_span(t(), map()) :: t()

start_iteration_span(obs, metadata)

@spec start_iteration_span(t(), map()) :: t()

start_llm_span(obs, metadata)

@spec start_llm_span(t(), map()) :: t()

start_tool_span(obs, call)

@spec start_tool_span(t(), map()) :: t()

summarize_conversation(state)

@spec summarize_conversation(map()) :: String.t()

Summarizes the conversation state for span metadata.