class LittleGhost::Tools::WriteTodos
WriteTodos lets an agent share a live plan with the application and the person following its work. Add it like any other tool:
class ResearchAgent < LittleGhost::Agent tools LittleGhost::Tools::WriteTodos end
Each execution replaces the full plan in RunContext state. Todo IDs remain stable across updates, statuses are pending, in_progress, or completed, and no more than one todo may be in progress. When no context is available, the tool retains fallback state on its instance.
Public Instance Methods
Source
# File lib/little_ghost/tools/write_todos.rb, line 55 def call(input) todos = input.fetch("todos") raise ToolError, "only one todo may be in progress" if todos.count { |todo| todo["status"] == "in_progress" } > 1 ids = todos.map { |todo| todo.fetch("id") } raise ToolError, "todo IDs must be unique" unless ids.uniq.length == ids.length state = context ? (context.state["little_ghost.plan"] ||= empty_plan) : (@fallback_state ||= empty_plan) state.replace("plan_title" => input.fetch("plan_title"), "todos" => todos.map(&:dup)) state.dup end
Replaces the stored plan after enforcing progress and ID invariants.
# File lib/little_ghost/tools/write_todos.rb, line 50 def execute(input, context: nil) super(normalize_titles(input), context:) end
Trims user-facing titles before normal tool validation and execution.
Calls superclass method
LittleGhost::Tool#execute