Skip to content

Learning loop broken: no mechanism to persist session insights on exit-and-resume #8

@jcmrs

Description

@jcmrs

Summary

OpenOwl's learning loop is broken for the common exit-and-resume workflow. Insights generated during a session are not persisted to cerebrum.md because the session lifecycle hooks available in OpenCode don't cover the resume case.

Problem

When a user exits and resumes a session (the most common workflow), OpenOwl has no mechanism to capture and persist insights. The current approach relies on the model voluntarily writing to cerebrum.md, which nothing triggers or reminds it to do.

OpenCode Plugin Lifecycle Events

From the official docs at https://opencode.ai/docs/plugins/:

Available session events:

  • session.created — fires on new session creation
  • session.deleted — fires on session deletion
  • session.updated — fires on session update (generic)
  • session.idle — fires when session goes idle
  • session.compacted — fires on context compaction
  • session.error — fires on session error
  • session.status — fires on status change
  • session.diff — fires on diff events

Critically: there is no session.resumed event. When a user exits and resumes, it likely fires session.updated or session.status, not session.created.

Why This Matters

  • session.created only fires for fresh sessions — exit-and-resume never triggers it
  • session.idle fires when the session goes idle, but a user can exit without the session entering idle state, and resume without a new session.created
  • session.updated is a generic event — using it as a proxy for resume would require inspecting event properties to detect the transition
  • The model is told via AGENTS.md to write learnings to cerebrum.md, but nothing in the plugin triggers this — the instruction is in a file the model is told not to read

Proposed Approaches

  1. Use session.idle for learn-back — On idle, generate a summary of session insights and persist to cerebrum.md. This covers the case where the user steps away (even if they resume later).

  2. Use session.updated as resume proxy — Detect resume transitions in session.updated event properties and trigger learn-back or re-initialization.

  3. Tool-based debounce (no lifecycle dependency) — Track insights during tool.execute.after and periodically flush to cerebrum.md based on accumulated changes, not session lifecycle.

  4. Compaction hook injection — Use experimental.session.compacting to inject a "persist your learnings" prompt before compaction, leveraging the model's own summary capability.

  5. SDK SSE stream — Use event.subscribe() to detect session transitions with more granularity than individual hook events provide.

Related

  • memory.md auto-logs tool actions (reads, writes) — this works because it writes on every tool.execute.after
  • cerebrum.md has no auto-logging — the learning loop is one-way (injection in, no persistence out)
  • The daemon's cron tasks (cerebrum-reflection) could consolidate entries but can't create them from scratch

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions