Module: SolidAgent::Records

Defined in:
lib/solid_agent/records.rb,
lib/solid_agent/records/agent.rb,
lib/solid_agent/records/ownable.rb,
lib/solid_agent/records/agent_run.rb,
lib/solid_agent/records/agent_version.rb,
lib/solid_agent/records/agent_template.rb

Overview

Behavior for the agent-configuration records: the agent itself, its version history, the templates it can be created from, and its runs.

The gem ships behavior only. The model classes are host-owned — generated into app/models by rails generate solid_agent:agents — and the gem never defines or requires the Agent, AgentVersion, AgentTemplate or AgentRun constants. That is deliberate, for three reasons:

  • ActiveAgent's dashboard cannot depend on solid_agent — solid_agent already depends on activeagent, so the reverse edge would be a cycle. Naming the models with configurable strings and resolving them at call time is what lets both the dashboard and a plain host app read the same tables without either gem requiring the other.
  • Engine-namespacing them as SolidAgent::Agent would make isolate_namespace resolve the table to solid_agent_agents, and would invalidate the contextable_type: "Agent" strings already persisted in production agent_contexts rows.
  • Agent configuration is the thing applications most want to extend. A host-owned model can be edited; a gem-owned one can only be monkey-patched.

Examples:

Resolving the configured model

SolidAgent.agent_model            #=> Agent
SolidAgent.agent_model_name       #=> "Agent"
SolidAgent.records_installed?     #=> true

Pointing at differently-named models

SolidAgent.configure do |config|
  config.agent_class = "Ai::Assistant"
  config.agent_run_class = "Ai::AssistantRun"
end

Defined Under Namespace

Modules: Agent, AgentRun, AgentTemplate, AgentVersion, Ownable

Constant Summary collapse

MODELS =

Model names the gem resolves lazily, and their defaults.

{
  agent_class: "Agent",
  agent_version_class: "AgentVersion",
  agent_template_class: "AgentTemplate",
  agent_run_class: "AgentRun"
}.freeze