DEV Community

Cover image for Building Shared Memory with AI
synthaicode
synthaicode

Posted on

Building Shared Memory with AI

AI has no sense of time. It only knows what's in the context window.

The Time Perception Gap

Humans and AI experience time differently.

AI: No intrinsic time awareness. Only knows temporal relationships when explicitly stated in context. "Yesterday" means nothing without a reference point.

Humans: Rarely think in absolute time. We remember events relative to other events. "After the launch." "Before the refactor." "When we fixed that bug."

This mismatch creates problems.

You say: "Remember when we discussed the authentication approach?"
AI sees: Nothing. That conversation isn't in context.

You think in events. AI thinks in tokens. Without a bridge, shared history doesn't exist.


The Bridge: Logs That AI Writes

The solution isn't documentation—it's AI-generated logs.

Who Writes Result
Human writes logs Incomplete, biased toward what human noticed
AI writes logs Captures what AI processed, enables AI recall

When AI writes the log, it records events only:

  • What was decided (not why it's good)
  • What was discussed (not what it means)
  • What human judged (as stated fact)
  • What was deferred (not whether that's wise)

No interpretation. No analysis. Just events.

The log is a record of what happened, not a commentary on what happened. Interpretation is human work, done when reading logs—not AI work done when writing them.

This isn't meeting minutes. It's event capture for future reference.


How It Works in Practice

AI Logs Automatically

Don't micromanage when AI should log. Let AI decide.

After significant discussions, decisions, or work sessions, AI records what happened. The format is simple:

## 2024-07-15: Authentication Decision

### Event
Discussed OAuth vs JWT for user authentication.

### Decision
Selected OAuth.

### Human's stated reason
"OAuth is simpler for external provider integration."

### Noted for later
"Revisit JWT if scaling issues appear." (human stated)

### Open
Token refresh strategy not decided.
Enter fullscreen mode Exit fullscreen mode

Notice: no AI opinion on whether OAuth is actually simpler. Just what human said.

You can request logs explicitly: "Log this decision." But the default is AI initiative.

Human Reviews, Doesn't Write

Your role: review logs for accuracy, not create them.

AI captures what happened. You verify it matches the facts. This division works because:

  • AI recorded the events as they occurred
  • Human confirms the record is accurate
  • Neither party does work they're bad at

Recalling Across Sessions

With logs in place, past context becomes accessible:

You: "What was the trade-off we noted when choosing OAuth?"

AI (reading logs): "We noted JWT might scale better for internal services. You said to revisit if scaling issues appear."

The log bridges the context gap. You reference events naturally. AI retrieves the relevant context.


Context Rollback

When results aren't what you wanted, don't think "go back in time."

Think: restore context to a known good state.

AI has no memory of time passing. It only knows what's in the current context. This is a feature, not a limitation. It means you can "rewind" by simply providing earlier context.

Methods of Context Rollback

Method How It Works
Git commit Checkout code to the target commit. AI sees the codebase as it was.
Log state Provide logs only up to the rollback point. Later decisions disappear.
Document version Load specifications/plans from the earlier state.

The key insight: align all artifacts to the target state.

If you rollback code but keep current logs, AI sees contradictions. If you rollback logs but keep current code, AI gets confused.

Everything must be consistent:

  • Code state
  • Log state
  • Document state
  • Plan state

When these align, AI operates as if the later work never happened. Because for AI, it didn't—it's not in context.

Practical Example

You built a feature. It's not working as intended. You want to try a different approach.

Wrong way: "Forget what we just built and try again."

  • AI still sees references to the failed approach
  • Context is polluted with mixed states
  • Results are inconsistent

Right way:

  1. Identify the rollback point (e.g., commit before feature branch)
  2. Checkout that commit
  3. Load logs only up to that point
  4. Provide the original plan/spec
  5. Start fresh with clean context

AI now operates from a consistent earlier state. The failed attempt doesn't exist in its world.

Why This Works

Human Intuition AI Reality
"Let's undo the last two weeks" Load context from two weeks ago
"Pretend that didn't happen" Don't include it in context—then it didn't
"Start over but remember lessons" Include only the learnings, not the failed implementation

For AI, context is reality. Control the context, control the reality.


Surviving Context Limits

Every AI has a context window limit. Long projects eventually exceed it.

Without shared memory:

  • You lose early decisions
  • You repeat discussions
  • AI contradicts previous conclusions
  • Continuity breaks

With shared memory:

  • Logs compress past context
  • Plan maintains direction
  • You reload what's relevant
  • Work continues seamlessly

The Reload Pattern

When context limit approaches:

  1. Summarize current state into logs
  2. Start new session with:
    • Project plan (goals, structure)
    • Relevant logs (compressed history)
    • Current focus (immediate task)

This is planned context management, not desperate recovery.


Multi-Phase Projects

For projects spanning weeks or months:

Phase 1: Requirements gathering
  → Logs: decisions, constraints identified

Phase 2: Design
  → Logs: architecture choices, trade-offs
  → Inherits Phase 1 logs

Phase 3: Implementation  
  → Logs: technical decisions, issues encountered
  → Inherits Phase 1-2 logs (summarized)

Phase 4: Review
  → Full access to decision history
Enter fullscreen mode Exit fullscreen mode

Each phase builds on previous context without requiring the full conversation history.


What to Log

Not everything deserves a log entry. Focus on:

Log This Skip This
Decisions made Routine work
What human stated as reason AI's interpretation of why
Alternatives discussed Obvious paths not taken
Open items explicitly noted Implicitly resolved matters
Events that change direction Events that continue direction

The test: "Is this a fact about what happened, or an interpretation of what it means?"

Log facts. Skip interpretations.


The Event-Based Mental Model

Remember: humans think in events, not timestamps.

Structure your logs around events:

  • "After we discovered the performance issue..."
  • "Before implementing the cache..."
  • "When the requirements changed..."

This makes logs naturally retrievable. You ask about events. AI finds logs by events.

Your memory model becomes AI's retrieval model.


Summary

Problem Solution
AI has no time sense Logs provide temporal context
Context windows have limits Logs enable reload and continuation
History gets lost between sessions Logs preserve what happened
Human memory is event-based Logs organized by events match human recall

Let AI write the logs. Review but don't author. Use logs as restore points.

Shared memory isn't about AI remembering. It's about making the past loadable.


This is part of the "Beyond Prompt Engineering" series, exploring how structural and cultural approaches outperform prompt optimization in AI-assisted development.

Top comments (0)