Class: RubyLLM::Agents::RetentionJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/ruby_llm/agents/infrastructure/retention_job.rb

Overview

Background job that enforces two-tier data retention on execution records.

Soft pass: for executions older than Configuration#soft_purge_after, destroys the associated execution_details and tool_executions rows, preserves a truncated copy of error_message in metadata, and stamps metadata so the dashboard can surface the state and the pass stays idempotent.

Hard pass: for executions older than Configuration#hard_purge_after, destroys the executions row itself. The foreign-key cascade removes any remaining details or tool_executions.

Either tier may be set to nil in configuration to skip that pass.

Examples:

Enqueue manually

RubyLLM::Agents::RetentionJob.perform_later

Schedule daily (whenever gem)

every 1.day, at: "3:00 am" do
  runner "RubyLLM::Agents::RetentionJob.perform_later"
end

Constant Summary collapse

ERROR_MESSAGE_MAX_LENGTH =
500
BATCH_SIZE =
500

Instance Method Summary collapse

Instance Method Details

#performHash

Runs the soft and hard retention passes based on current configuration.

Returns:

  • (Hash)

    counts of rows affected in each pass



37
38
39
40
41
42
# File 'lib/ruby_llm/agents/infrastructure/retention_job.rb', line 37

def perform
  {
    soft_purged: soft_purge,
    hard_purged: hard_purge
  }
end