class LittleGhost::Agent

Defines one reusable model-driven behavior with prompts, tools, and limits. Each Agent subclass describes one application role with an inheritable Ruby DSL. It can answer, stream, call tools, and delegate work.

Start with one role and add capabilities as its work grows:

class CustomerSupportAgent < LittleGhost::Agent
  description "Handles support requests"
  model "openrouter:openai/gpt-5.6-luna"
  system_prompt "Answer customer questions clearly."
end

run = CustomerSupportAgent.ask("Why is transfer 481 pending?")
run.completed? # => true
run.response
# One possible response: Transfer 481 is waiting for the receiving bank.

An Agent is the smallest Assembly: it owns one model loop while inheriting the same ask and stream_ask entrypoints as coordinated assemblies. Add tools for application operations and subagents for model-directed delegation.

Call a named Agent with ask when you need the final Run, or the streaming entrypoint when you want events as the answer arrives.

Most applications call a named Agent class. LittleGhost automatically reuses the active Configuration’s shared Runtime while building a fresh top-level Run for every call. Passing runtime: is an advanced option for an explicitly isolated setup.

Agent declarations are inherited. Define a short prompt inline, or place a growing prompt in app/prompts/customer_support/system.erb for CustomerSupportAgent. The Prompts as Views guide explains conventional lookup, locals, and partials. Optional features such as skills, context management, loop detection, and delegation stay inactive until their DSL is used.

Models may return text or locally validated structured data. LittleGhost hides unexpected Tool exception messages from the model. See Run for outcomes, cancellation, and cleanup, and Assembly for the advanced run-scoped form.