Skip to content

Question: Intentional that before_reset hook is unused for context preservation? #133

@mtsogias

Description

@mtsogias

Correction to Original Issue

The original issue incorrectly stated that no hook exists for session reset events. That was wrong.

OpenClaw's plugin SDK already provides before_reset as a PluginHookName (defined in plugins/types.d.ts, type PluginHookBeforeResetEvent). The hook fires before /new or idle-timeout resets. lossless-claw v0.4.0 does not register a handler for it — in fact, the plugin uses no api.on() hooks at all.

Question

Is this intentional?

We can see reasons why it would be:

  1. Messages are persistent. Nothing is physically lost on /new. Everything stays in lcm.db and is recoverable via lcm_grep / lcm_expand.
  2. Forced compaction on thin context = poor summaries. If someone runs /new after 3 messages, a forced summary would fragment the DAG with low-quality nodes.
  3. The LCM tools ARE the recovery mechanism. Four retrieval tools exist specifically for reaching into past conversations — whether summarized or not.
  4. The plugin deliberately uses only the ContextEngine interface, not event hooks. This looks like an architectural choice, not an oversight.

So the philosophy may be: "Summarize only when context-window pressure demands it, not prophylactically. The data is safe, the tools can find it."

Our Use Case

We added a before_reset handler (~40 lines) that forces compaction before /new resets. The motivation: when a new session starts, assemble() only returns summaries + fresh tail from the current conversation. Without a summary from the previous conversation, the agent starts with zero carried-over context — even though the raw messages exist in the DB.

The LCM tools can recover this, but it requires the agent (or user) to actively search for prior context. A summary written at reset would make context carryover automatic via assemble().

We're not sure this is the right trade-off. Forced summaries on short conversations would be noisy. But for longer conversations that reset before hitting the compaction threshold, it feels like a gap.

Is there a design reason this was left out, or would a PR with an opt-in compactOnReset: true config flag be welcome?

Environment

  • OpenClaw: 2026.3.13+
  • lossless-claw: 0.4.0
  • before_reset hook available in SDK since at least current OpenClaw release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions