LLMAgent.Tasks (llm_agent v0.2.0)
View SourceManages long-running tasks using AgentForge's execution capabilities.
This module provides functions for starting, monitoring, and controlling tasks that are implemented as sequences of AgentForge primitives, supporting complex flow patterns with branching, waiting conditions, and fine-grained state management.
Summary
Functions
Attempts to cancel a running task.
Gets the latest statistics for a task.
Attempts to pause a running task.
Attempts to resume a paused task.
Starts a task with the given definition and parameters.
Functions
Attempts to cancel a running task.
Parameters
_task_id
- The ID of the task to cancel
Returns
:ok
- If the task was successfully cancelled{:error, reason}
- If the task could not be cancelled
Gets the latest statistics for a task.
Parameters
task_id
- The ID of the task
Returns
A map of task statistics including stage information.
Attempts to pause a running task.
Parameters
_task_id
- The ID of the task to pause
Returns
:ok
- If the task was successfully paused{:error, reason}
- If the task could not be paused
Attempts to resume a paused task.
Parameters
_task_id
- The ID of the task to resume
Returns
:ok
- If the task was successfully resumed{:error, reason}
- If the task could not be resumed
Starts a task with the given definition and parameters.
Parameters
task_def
- The task definition as a list of AgentForge primitivesparams
- Parameters for the taskstate
- The current agent stateopts
- Additional options for task execution
Returns
A tuple containing the task ID and a task state signal.
Examples
iex> task_def = [
...> AgentForge.Primitives.transform(fn data -> Map.put(data, :processed, true) end)
...> ]
iex> params = %{data: "test"}
iex> state = %{}
iex> {task_id, signal} = LLMAgent.Tasks.start(task_def, params, state)
iex> is_binary(task_id) and signal.type == :task_state
true