Use case
Score every inbound lead in your Rails CRM.
A structured-output agent, a Sidekiq job, and a Postgres column. That is the whole pipeline.
The agent
class LeadScorer < RailsAgents::Base
model "gpt-4o-mini"
schema do
number :score, min: 0, max: 100
string :segment, enum: %w[smb mid enterprise]
string :reason
end
instructions "Score this lead's fit for a Rails-first SaaS."
endAsync scoring
class ScoreLeadJob < RailsAgent::AgentJob
agent LeadScorer
def on_success(result, lead:)
lead.update!(ai_score: result.score, segment: result.segment)
end
end