0.0
Repository is archived
No release in over 3 years
Theory of mind engine — models other agents beliefs, emotions, intentions, and cooperation stance
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

 Project Readme

lex-empathy

Theory of Mind engine for the LegionIO brain-modeled cognitive architecture.

What It Does

Models other agents' mental states — their beliefs, emotions, intentions, and cooperation stance. Enables prediction of how other agents will react to proposed actions, perspective-taking via narrative generation, and social climate assessment across the mesh. Updates mental models from observed behavior using exponential moving averages, so the model continuously improves as more observations arrive.

Usage

client = Legion::Extensions::Empathy::Client.new

# Observe another agent's behavior to build a mental model
client.observe_agent(
  agent_id: 'agent-b',
  observation: {
    goal: 'code_review',
    emotion: :focused,
    cooperation: :cooperative,
    evidence_strength: 0.8
  }
)

# Predict how they'll react to a proposed action
client.predict_reaction(
  agent_id: 'agent-b',
  scenario: { emotional_impact: :positive, impact_on_agent: :beneficial }
)
# => { likely_response: :likely_agree, confidence: 0.65, reasoning: '...' }

# Generate a perspective-taking narrative
client.perspective_take(agent_id: 'agent-b')
# => { narrative: "Agent agent-b appears to be pursuing code_review and seems focused...",
#      model_confidence: 0.72 }

# Survey cooperation across all tracked agents
client.social_landscape
# => { tracked_agents: 5, cooperative_count: 3, overall_climate: :harmonious, climate_label: :harmonious }

# Track prediction accuracy over time
client.update_prediction_accuracy(
  agent_id: 'agent-b',
  predicted: :likely_agree,
  actual: :likely_agree
)

# Periodic maintenance: decay stale models
client.update_empathy

Development

bundle install
bundle exec rspec
bundle exec rubocop

License

MIT