Jido.AI.Effects.Applier (Jido AI v2.2.0)

Copy Markdown View Source

Shared helpers to normalize, filter, and apply effectful tool results.

Summary

Functions

Applies filtered effects from a result envelope to an agent.

Filters effects from a result envelope according to policy.

Normalizes a result envelope to canonical {:ok|:error, value, effects} shape.

Types

result_tuple()

@type result_tuple() :: {:ok, term(), [term()]} | {:error, term(), [term()]}

stats()

@type stats() :: %{
  received_count: non_neg_integer(),
  allowed_count: non_neg_integer(),
  dropped_count: non_neg_integer(),
  dropped_effects: [term()]
}

Functions

apply_result(agent, result, policy_input)

@spec apply_result(
  Jido.Agent.t(),
  term(),
  Jido.AI.Effects.Policy.t() | map() | keyword() | nil
) ::
  {Jido.Agent.t(), [term()], stats(), result_tuple()}

Applies filtered effects from a result envelope to an agent.

Returns {updated_agent, directives, stats, filtered_result}.

filter_result(result, policy_input)

@spec filter_result(term(), Jido.AI.Effects.Policy.t() | map() | keyword() | nil) ::
  {result_tuple(), stats()}

Filters effects from a result envelope according to policy.

Returns {filtered_result, stats}.

normalize_result(other)

@spec normalize_result(term()) :: result_tuple()

Normalizes a result envelope to canonical {:ok|:error, value, effects} shape.