Module: Legion::Extensions::Agentic::Social::Conflict::Helpers::LlmEnhancer

Defined in:
lib/legion/extensions/agentic/social/conflict/helpers/llm_enhancer.rb

Constant Summary collapse

SYSTEM_PROMPT =
<<~PROMPT
  You are the conflict mediation processor for an autonomous AI agent built on LegionIO.
  You analyze disagreements between the agent and human partners, then suggest resolution approaches.
  Be neutral, constructive, and specific. Focus on finding common ground and actionable next steps.
  Do not take sides. Identify the underlying needs behind each position.
PROMPT

Class Method Summary collapse

Class Method Details

.analyze_stale_conflict(description:, severity:, age_hours:, exchange_count:) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/legion/extensions/agentic/social/conflict/helpers/llm_enhancer.rb', line 34

def analyze_stale_conflict(description:, severity:, age_hours:, exchange_count:)
  prompt = build_analyze_stale_conflict_prompt(
    description:    description,
    severity:       severity,
    age_hours:      age_hours,
    exchange_count: exchange_count
  )
  response = llm_ask(prompt)
  parse_analyze_stale_conflict_response(response)
rescue StandardError => e
  Legion::Logging.warn "[conflict:llm] analyze_stale_conflict failed: #{e.message}"
  nil
end

.available?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/legion/extensions/agentic/social/conflict/helpers/llm_enhancer.rb', line 19

def available?
  defined?(Legion::LLM) && Legion::LLM.respond_to?(:started?) && Legion::LLM.started?
rescue StandardError => _e
  false
end

.suggest_resolution(description:, severity:, exchanges:) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/legion/extensions/agentic/social/conflict/helpers/llm_enhancer.rb', line 25

def suggest_resolution(description:, severity:, exchanges:)
  prompt = build_suggest_resolution_prompt(description: description, severity: severity, exchanges: exchanges)
  response = llm_ask(prompt)
  parse_suggest_resolution_response(response)
rescue StandardError => e
  Legion::Logging.warn "[conflict:llm] suggest_resolution failed: #{e.message}"
  nil
end