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 53 def call(input) todos = input.fetch("todos") if todos.count { |todo| todo["status"] == "in_progress" } > 1 raise ToolError, framework_prompt("tools/built_in/write_todos/feedback/single_progress") end ids = todos.map { |todo| todo.fetch("id") } raise ToolError, framework_prompt("tools/built_in/write_todos/feedback/unique_ids") unless ids.uniq.length == ids.length if context context.state["little_ghost.plan"] ||= empty_plan state = context.state.fetch("little_ghost.plan") else state = @fallback_state ||= empty_plan end 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.
Source
# File lib/little_ghost/tools/write_todos.rb, line 48 def description framework_prompt("tools/built_in/write_todos/description") end
# File lib/little_ghost/tools/write_todos.rb, line 44 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