Jido.AI.Plugins.TaskSupervisor (Jido AI v2.1.0)

View Source

Plugin that creates and manages a per-instance Task.Supervisor for Jido.AI agents.

In Jido 2.0, each agent instance requires its own task supervisor to properly scope async operations (like LLM streaming and tool execution) to the agent's lifecycle.

This plugin is automatically added to Jido.AI agents to handle supervisor creation and cleanup.

Supervisor Storage

The supervisor PID is stored in agent.state.__task_supervisor_skill__ (the plugin's internal state) and is accessed by directives via Directive.Helpers.get_task_supervisor/1.

Lifecycle

  • mount: Creates a new anonymous Task.Supervisor
  • Automatic cleanup: The linked supervisor terminates when the agent stops

Usage

This plugin is automatically included when using Jido.AI.Agent. Manual inclusion is not typically needed.

Implementation Notes

This plugin has no actions - it only provides lifecycle hooks for supervisor management. The supervisor PID is stored in the plugin's state under the internal key __task_supervisor_skill__.

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.

Initialize plugin state when mounted to an agent.

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.

mount(agent, config)

@spec mount(term(), map()) :: {:ok, map() | nil} | {:error, term()}

Initialize plugin state when mounted to an agent.

Creates and stores the Task.Supervisor PID.

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() :: [tuple()]

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.