JidoGralkor.Actions.MemorySearch (jido_gralkor v1.0.5)

Copy Markdown View Source

ReAct tool the LLM can call to search long-term memory.

Calls the client's memory_search/3 callback with group_id sanitized from context[:agent_id] and session_id read from context[:session_id] (planted by JidoGralkor.Plugin on ai.react.query — the Jido thread id).

If session_id is absent or blank (the LLM called the tool on the very first query of a fresh agent, before the ReAct strategy committed a thread to agent state) the action short-circuits with an explicit non-result message — there is no session buffer to interpret against yet, and Gralkor requires a real session id. The message tells the LLM the search did not run, so it doesn't read an empty payload as "no memory exists" and confidently lie to the user. Errors from the client propagate.

Summary

Functions

Returns the Action metadata. Alias for to_json/0.

Returns the category of the Action.

Returns the description of the Action.

Returns the name of the Action.

Lifecycle hook called after Action execution.

Lifecycle hook called after output validation.

Lifecycle hook called after parameter validation.

Lifecycle hook called before output validation.

Lifecycle hook called before parameter validation.

Lifecycle hook called when an error occurs.

Returns the output schema of the Action.

Executes the Action with the given parameters and context.

Returns the input schema of the Action.

Returns the tags associated with the Action.

Returns the Action metadata as a JSON-serializable map.

Converts the Action to an LLM-compatible tool format.

Validates the output result for the Action.

Validates the input parameters for the Action.

Returns the version of the Action.

Functions

__action_metadata__()

Returns the Action metadata. Alias for to_json/0.

category()

Returns the category of the Action.

description()

Returns the description of the Action.

name()

Returns the name of the Action.

on_after_run(result)

Lifecycle hook called after Action execution.

on_after_validate_output(output)

Lifecycle hook called after output validation.

on_after_validate_params(params)

Lifecycle hook called after parameter validation.

on_before_validate_output(output)

Lifecycle hook called before output validation.

on_before_validate_params(params)

Lifecycle hook called before parameter validation.

on_error(failed_params, error, context, opts)

Lifecycle hook called when an error occurs.

output_schema()

Returns the output schema of the Action.

run(params, context)

Executes the Action with the given parameters and context.

The run/2 function must be implemented in the module using Jido.Action.

schema()

Returns the input schema of the Action.

tags()

Returns the tags associated with the Action.

to_json()

Returns the Action metadata as a JSON-serializable map.

to_tool()

Converts the Action to an LLM-compatible tool format.

validate_output(output)

@spec validate_output(map()) :: {:ok, map()} | {:error, String.t()}

Validates the output result for the Action.

Examples

iex> defmodule ExampleAction do
...>   use Jido.Action,
...>     name: "example_action",
...>     output_schema: [
...>       result: [type: :string, required: true]
...>     ]
...> end
...> ExampleAction.validate_output(%{result: "test", extra: "ignored"})
{:ok, %{result: "test", extra: "ignored"}}

iex> ExampleAction.validate_output(%{extra: "ignored"})
{:error, "Invalid output for Action: Required key :result not found"}

validate_params(params)

@spec validate_params(map()) :: {:ok, map()} | {:error, String.t()}

Validates the input parameters for the Action.

Examples

iex> defmodule ExampleAction do
...>   use Jido.Action,
...>     name: "example_action",
...>     schema: [
...>       input: [type: :string, required: true]
...>     ]
...> end
...> ExampleAction.validate_params(%{input: "test"})
{:ok, %{input: "test"}}

iex> ExampleAction.validate_params(%{})
{:error, "Invalid parameters for Action: Required key :input not found"}

vsn()

Returns the version of the Action.