JidoGralkor.Canonical (jido_gralkor v1.0.1)

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:

  • strip adapter-injected text the server should never see (the <gralkor-memory>…</gralkor-memory> recall envelope);
  • 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 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.