Skip to content

Add temporal awareness to context selection #9

@jeremiepas

Description

@jeremiepas

Problem

No time-based relevance scoring. A conversation from 6 months ago about authentication gets the same weight as one from yesterday. Memory agents should prioritize recent conversations.

Nodes have nodeCapturedAt but it's never used in context selection.

Solution

Add exponential decay to relevance scores based on node age.

Scoring formula:

recencyBoost(ts, now) = max(minBoost, maxBoost * exp(-λ * age_hours))
where λ = ln(2) / halfLife_hours

Decay table (halfLife = 7 days):

Age Boost
1 hour 2.00
1 day 1.91
7 days 1.00
30 days 0.17
60 days 0.10 (minimum)

Configuration (graphos.yaml):

temporal:
  half_life_days: 7
  max_boost: 2.0
  min_boost: 0.1

Acceptance Criteria

  • New module: UseCase.Temporal with recencyBoost function
  • selectContext uses temporal scoring when timestamps available
  • Nodes without timestamps get minimum boost (0.1)
  • Configurable half-life, max/min boost via graphos.yaml
  • Test: recencyBoost monotonically decreases over time
  • Test: recent nodes score higher than old nodes in select_context

Files to Create/Modify

  • src/Graphos/UseCase/Temporal.hs (NEW)
  • src/Graphos/UseCase/SelectContext.hs — integrate temporal boost
  • src/Graphos/Domain/Config.hs — add TemporalConfig
  • src/Graphos/Domain/Context.hs — add temporal fields to SelectedContext

Effort: 1 day

Priority: Medium

See: docs/proposals/memory-agent/05-technical-specifications.md (Spec 5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmemory-agentMemory agent capabilitiesphase-3Phase 3: LLM Summarization + Temporal

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions