game_memory

GameGirl Color – Two-tier game memory system.

Manages per-game memories in Redis with two tiers: - Basic: Important, long-lived (characters, plot, bosses, items) - Channel: Ephemeral, recent context (recent events, minor NPCs)

Includes hot-swap memory bleed logic for carrying context between cartridge swaps. # πŸ§ πŸ’€ CORRUPTED MEMORY BANKS

class game_memory.GameMemory(label, content, importance=0.5, turn_created=0, turn_last_referenced=0, reference_count=1, category='general', glitched=False, source_game='', created_at=<factory>)[source]

Bases: object

A single memory entry in the game’s memory bank.

Parameters:
  • label (str)

  • content (str)

  • importance (float)

  • turn_created (int)

  • turn_last_referenced (int)

  • reference_count (int)

  • category (str)

  • glitched (bool)

  • source_game (str)

  • created_at (float)

label: str
content: str
importance: float = 0.5
turn_created: int = 0
turn_last_referenced: int = 0
reference_count: int = 1
category: str = 'general'
glitched: bool = False
source_game: str = ''
created_at: float
to_dict()[source]
Return type:

dict[str, Any]

classmethod from_dict(d)[source]
Return type:

GameMemory

Parameters:

d (dict[str, Any])

async game_memory.store_basic(game_id, label, content, importance=0.7, category='general', turn=0, redis=None)[source]

Store or update a basic (important) memory.

Basic memories persist for the life of the game. Used for characters, plot points, bosses, key items, relationships.

Return type:

bool

Parameters:
async game_memory.store_channel(game_id, label, content, turn=0, redis=None)[source]

Store a channel (ephemeral) memory.

Channel memories are recent context β€” scene descriptions, minor NPCs, dialogue snippets. FIFO eviction. Auto-promoted to basic if referenced 3+ times.

Return type:

bool

Parameters:
async game_memory.get_basic_memories(game_id, redis=None)[source]

Get all basic memories for a game.

Return type:

list[GameMemory]

Parameters:
async game_memory.get_channel_memories(game_id, redis=None)[source]

Get all channel memories for a game.

Return type:

list[GameMemory]

Parameters:
async game_memory.get_context_summary(game_id, redis=None)[source]

Build a formatted memory context block for the system prompt.

Returns a string suitable for injection into the LLM context, organized by importance and category.

Return type:

str

Parameters:
async game_memory.bleed_memories(source_game_id, target_game_id, redis=None, max_bleed=7)[source]

Transfer important memories from source to target game.

Selects top memories by importance, with priority for: - Antagonists/bosses (category == β€˜boss’) - Active combat state - High-importance plot points

Bleeded memories get the glitched flag and source_game tag. Channel memories are discarded (ephemeral by design).

Returns a summary of what bled through.

Return type:

str

Parameters:
  • source_game_id (str)

  • target_game_id (str | None)

  • redis (Any)

  • max_bleed (int)

async game_memory.clear_game_memories(game_id, redis=None)[source]

Delete all memories for a game.

Return type:

None

Parameters: