Helper functions for DirectiveExec implementations.
This module centralizes directive runtime helpers for:
- Task supervisor resolution
- Model resolution from directive fields
- Message normalization/building
- Request option assembly
- Error classification
Summary
Functions
Adds req_http_options option to a keyword list if options are specified.
Adds timeout option to a keyword list if timeout is specified.
Adds tools option to a keyword list if tools are specified.
Builds messages for LLM calls from context and optional system prompt.
Classifies an error into a runtime category.
Gets the task supervisor from agent state.
Resolves a model from directive fields.
Functions
Adds req_http_options option to a keyword list if options are specified.
Adds timeout option to a keyword list if timeout is specified.
Adds tools option to a keyword list if tools are specified.
Builds messages for LLM calls from context and optional system prompt.
Classifies an error into a runtime category.
Returns one of: :rate_limit, :auth, :timeout, :provider_error,
:network, :validation, :unknown.
Gets the task supervisor from agent state.
First checks the TaskSupervisorSkill's internal state (__task_supervisor_skill__),
then falls back to the top-level :task_supervisor field for standalone usage.
Examples
iex> state = %{__task_supervisor_skill__: %{supervisor: supervisor_pid}}
iex> Jido.AI.Directive.Helpers.get_task_supervisor(state)
supervisor_pid
iex> state = %{task_supervisor: supervisor_pid}
iex> Jido.AI.Directive.Helpers.get_task_supervisor(state)
supervisor_pid
Resolves a model from directive fields.
Supports both direct model specification and model alias resolution.