Class: Assistant::SunnyAgent

Inherits:
RubyLLM::Agent
  • Object
show all
Defined in:
app/agents/assistant/sunny_agent.rb

Overview

RubyLLM Agent for the Sunny AI assistant, backed by persisted AssistantConversation records.

Serves as the canonical factory and configuration baseline for Sunny conversations.
The controller creates/finds conversations through this agent class; ChatService then
applies per-request runtime configuration (dynamic model selection, role-based tool
registration, extended thinking, Anthropic prompt-caching, lifecycle callbacks) before
each turn.

The instructions macro points to the base system prompt template
(app/prompts/assistant/sunny_agent/instructions.txt.erb). ChatService renders this
template and appends dynamic sections (user identity, tool rules, schema hints) before
handing off to the conversation.

Examples:

Creating a new conversation

conversation = Assistant::SunnyAgent.create!(user: current_user)
# => AssistantConversation record (create! returns the chat model directly)

Wrapping an existing conversation

conversation = Assistant::SunnyAgent.find(conversation_id)
# => AssistantConversation record

See Also: