Jido.AI.Plugins.Retrieval (Jido AI v2.2.0)

Copy Markdown View Source

Cross-cutting retrieval and memory enrichment plugin.

Provides in-process memory operations (retrieval.upsert, retrieval.recall, retrieval.clear) plus optional prompt enrichment for chat.message and reasoning.*.run signals.

Enrichment Lifecycle

For enrichable signals, handle_signal/2 runs this lifecycle:

  1. Read plugin state (enabled, namespace, top_k, max_snippet_chars).
  2. Skip when plugin-level enabled: false.
  3. Skip when request payload includes disable_retrieval: true (atom or string key).
  4. Extract query text from prompt/query fields.
  5. Recall top-k memories from Jido.AI.Retrieval.Store for the active namespace.
  6. If memories are found, rewrite payload :prompt with a "Relevant memory" block and attach retrieval metadata under :retrieval.

Signals without a query, and signals with no matching memories, continue unchanged.

Namespace Behavior

mount/2 resolves namespace in this order:

  1. Explicit plugin config (:namespace)
  2. Agent id (when available)
  3. "default"

The resulting namespace is shared by enrichment and retrieval actions unless callers override namespace in action params.

Opt-Out Controls

  • enabled: false disables enrichment for all requests on the mounted plugin.
  • disable_retrieval: true disables enrichment for one request while keeping retrieval routes available.

Usage

use Jido.AI.Agent,
  name: "retrieval_enabled_assistant",
  plugins: [
    {Jido.AI.Plugins.Retrieval,
     %{
       namespace: "weather_ops",
       top_k: 3,
       max_snippet_chars: 280
     }}
  ]

Summary

Functions

Returns metadata for Jido.Discovery integration.

Returns the list of action modules provided by this plugin.

Returns the capabilities provided by this plugin.

Returns the plugin's category.

Returns the Zoi schema for per-agent configuration.

Returns the plugin's description.

Returns the plugin manifest with all metadata.

Returns the plugin's name.

Returns the OTP application for config resolution.

Returns the plugin specification with optional per-agent configuration.

Returns the requirements for this plugin.

Returns the schedules for this plugin.

Returns the Zoi schema for plugin state.

Returns the signal patterns this plugin handles.

Returns the signal routes for this plugin.

Returns whether this plugin is a singleton.

Returns the key used to store plugin state in the agent.

Returns the sensor subscriptions for this plugin.

Returns the plugin's tags.

Returns the plugin's version.

Functions

__plugin_metadata__()

@spec __plugin_metadata__() :: map()

Returns metadata for Jido.Discovery integration.

This function is used by Jido.Discovery to index plugins for fast lookup and filtering.

actions()

@spec actions() :: [module()]

Returns the list of action modules provided by this plugin.

capabilities()

@spec capabilities() :: [atom()]

Returns the capabilities provided by this plugin.

category()

@spec category() :: String.t() | nil

Returns the plugin's category.

config_schema()

@spec config_schema() :: Zoi.schema() | nil

Returns the Zoi schema for per-agent configuration.

description()

@spec description() :: String.t() | nil

Returns the plugin's description.

manifest()

@spec manifest() :: Jido.Plugin.Manifest.t()

Returns the plugin manifest with all metadata.

The manifest provides compile-time metadata for discovery and introspection, including capabilities, requirements, signal routes, and schedules.

name()

@spec name() :: String.t()

Returns the plugin's name.

otp_app()

@spec otp_app() :: atom() | nil

Returns the OTP application for config resolution.

plugin_spec(config \\ %{})

@spec plugin_spec(map()) :: Jido.Plugin.Spec.t()

Returns the plugin specification with optional per-agent configuration.

Examples

spec = MyModule.plugin_spec(%{})
spec = MyModule.plugin_spec(%{custom_option: true})

requires()

@spec requires() :: [tuple()]

Returns the requirements for this plugin.

schedules()

@spec schedules() :: [tuple()]

Returns the schedules for this plugin.

schema()

@spec schema() :: Zoi.schema() | nil

Returns the Zoi schema for plugin state.

signal_patterns()

@spec signal_patterns() :: [String.t()]

Returns the signal patterns this plugin handles.

signal_routes()

@spec signal_routes() :: [tuple()]

Returns the signal routes for this plugin.

singleton?()

@spec singleton?() :: boolean()

Returns whether this plugin is a singleton.

state_key()

@spec state_key() :: atom()

Returns the key used to store plugin state in the agent.

subscriptions()

@spec subscriptions() :: [Jido.Plugin.sensor_subscription()]

Returns the sensor subscriptions for this plugin.

tags()

@spec tags() :: [String.t()]

Returns the plugin's tags.

vsn()

@spec vsn() :: String.t() | nil

Returns the plugin's version.