Sagents.Todo (Sagents v0.7.0)

Copy Markdown

TODO item structure for task tracking.

TODOs help agents break down complex tasks into manageable steps and track progress through multi-step workflows.

Status Values

  • :pending - Task not yet started
  • :in_progress - Currently being worked on
  • :completed - Task finished successfully
  • :cancelled - Task no longer needed

Usage

# Create a new TODO
{:ok, todo} = Todo.new(%{
  content: "Implement user authentication",
  status: :pending
})

# Update status
{:ok, updated} = Todo.new(%{
  id: todo.id,
  content: todo.content,
  status: :in_progress
})

Summary

Functions

Create a TODO from a map (for deserialization).

Create a new TODO item with validation.

Create a new TODO item, raising on error.

Convert a TODO struct to a map for serialization.

Types

t()

@type t() :: %Sagents.Todo{
  content: String.t(),
  id: String.t(),
  status: :pending | :in_progress | :completed | :cancelled
}

Functions

from_map(map)

Create a TODO from a map (for deserialization).

Examples

map = %{"id" => "123", "content" => "Task", "status" => "pending"}
{:ok, todo} = Todo.from_map(map)

new(attrs \\ %{})

Create a new TODO item with validation.

Generates a unique ID if not provided.

Examples

{:ok, todo} = Todo.new(%{content: "Write tests"})
{:ok, todo} = Todo.new(%{id: "custom-id", content: "Task", status: :completed})

new!(attrs \\ %{})

Create a new TODO item, raising on error.

Examples

todo = Todo.new!(%{content: "Deploy to production"})

to_map(todo)

Convert a TODO struct to a map for serialization.

Examples

todo = Todo.new!(%{content: "Task"})
map = Todo.to_map(todo)
# => %{"id" => "...", "content" => "Task", "status" => "pending"}