Skip to content

[Enhancement] Feed Narcissus consciousness insights back into therapy prompts #21

@LarytheLord

Description

@LarytheLord

Goal

Narcissus records cognitive states and detects patterns — but this data is never fed back into the LLM prompts. The agent should be self-aware of its own therapeutic patterns and adjust.

Inspired by: GödelOS (strange-loop concept — system observes its own state), CoALA (metacognitive controller)

Current state

In km_agent.py, step 2 (PATTERNS) collects patterns but only passes them as a flat list:

patterns = self.state_tracker.detect_stuck_patterns(patient_id)
patterns_str = "\n".join(f"  - {p}" for p in patterns)

The Narcissus get_self_awareness_metrics() data is returned in the API response but never influences generation.

Fix

Add consciousness self-model to both the ASSESSMENT and RESPONSE prompts:

# Get full consciousness insights
consciousness = self.state_tracker.get_self_awareness_metrics(patient_id)

consciousness_str = f"""
Agent self-awareness (from Narcissus introspection):
- Sessions tracked: {consciousness.get('sessions_tracked', 0)}
- Dominant intervention pattern: {consciousness.get('most_used_intervention', 'none')}
- Patient engagement trend: {consciousness.get('engagement_trend', 'unknown')}
- Detected biases in my approach: {patterns_str}
- Self-awareness depth: {consciousness.get('self_awareness_depth', 'low')}

Use this self-knowledge to AVOID repeating ineffective approaches.
If I've been using the same intervention repeatedly, try a different one.
If patient engagement is declining, shift my therapeutic style.
"""

Add {consciousness_str} to both ASSESSMENT_PROMPT and RESPONSE_PROMPT.

Expected behavior change

  • If agent has used cognitive_restructuring 5 times in a row → it should try journaling_prompt instead
  • If patient engagement is declining → agent should ask more open questions, reduce structured exercises
  • If agent detects its own "confirmation bias" → it should consider alternative interpretations

Impact

  • True self-aware therapy agent — adjusts based on its own performance patterns
  • Prevents therapeutic ruts (same technique every session)
  • Zero extra API cost — consciousness data is already computed, just adding it to the prompt
  • This is the "strange loop" — the agent thinking about its own thinking

Depends on

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions