JidoGralkor.Canonical (jido_gralkor v1.0.7)

Copy Markdown View Source

Converts a Jido/ReAct turn into Gralkor's canonical message shape.

Gralkor accepts a flat list of %Gralkor.Message{role, content} where role ∈ {"user", "assistant", "behaviour"}. Adapter responsibility:

  • render the Jido ReAct event trace into "behaviour" messages using whatever textual form reads well for distillation;
  • filter events that aren't memory-worthy.

The user_query passed in is expected to be the user's actual words — not enriched with memory blocks, identity envelopes, or any other harness-injected context. In the hexagonal split, prompt-time enrichment belongs in a Jido.AI.Reasoning.ReAct.RequestTransformer that wraps context for the LLM but leaves :query alone, so downstream state (buffer, request store, capture) never carries injected junk.

The server never branches on interior structure — only on role. The LLM is forgiving about the exact behaviour wording, so the rendering here is free to evolve.

Summary

Functions

Normalise a Jido/ReAct turn into a list of canonical Gralkor messages.

Types

outcome()

@type outcome() :: {:completed, String.t()} | {:failed, term()}

Functions

to_messages(user_query, events, outcome)

@spec to_messages(String.t(), [map()], outcome()) :: [Gralkor.Message.t()]

Normalise a Jido/ReAct turn into a list of canonical Gralkor messages.

Returns [] when there's nothing worth persisting — callers use that to skip the capture call entirely.