feat: implement /new vs /reset session lifecycle semantics#195
Merged
Conversation
This was referenced Mar 27, 2026
Closed
jalehman
added a commit
that referenced
this pull request
Mar 31, 2026
Align /new retention semantics with review feedback. When newSessionRetainDepth is -1, lossless-claw now leaves existing context_items untouched instead of dropping fresh-tail messages. Depth 0 remains the mode that drops only fresh-tail messages while keeping all summaries. Updated README, configuration docs, manifest help text, and lifecycle tests to match the behavior. Regeneration-Prompt: |\n Review feedback on PR #195 questioned whether the documented -1 /new retain depth should still drop fresh-tail messages. Keep the broader /new versus /reset lifecycle design intact, but make the narrow semantic change that -1 becomes a true no-op from lossless-claw's perspective by preserving all existing context items. Preserve 0 as the mode that drops only fresh-tail messages while keeping all summaries, then update docs and focused lifecycle tests so the distinction is explicit and verified.
Add active/archive conversation lifecycle support so /reset can archive the current conversation and create a fresh active row while keeping the stable session_key. Register before_reset handling for both /new and /reset, add configurable /new pruning depth, and cover the lifecycle with focused migration, engine, config, and regression tests. Documentation now explains the plugin-owned behavior and the boundary for user-facing command text. Regeneration-Prompt: | Implement the 2026-03-26 Lossless Claw /new vs /reset spec from the pagedrop. Preserve the existing model where /new only trims the active conversation's fresh context, but make /reset archive the current conversation and create a new active conversation for the same stable session_key. The existing schema enforced global uniqueness on session_key, so replace that with active-row-only uniqueness and keep archived rows carrying the same key for history and auditing. Wire the behavior through the before_reset hook, add configuration for how much summary depth /new retains, update docs to explain that this repo owns the lifecycle behavior but not the OpenClaw user-facing confirmation text, and add regression coverage for migration, active-row lookup, pruning, reset archiving, and repeated reset on an already-fresh conversation.
Add maintainer-owned release metadata for the /new vs /reset lifecycle work so the feature is reviewable and release-ready under this repo's Changesets workflow. Regeneration-Prompt: | The /new vs /reset lifecycle feature changes user-visible plugin behavior, so this branch needs a maintainer-authored Changesets entry before review. Add a release note for @martian-engineering/lossless-claw that captures the new semantics: /new prunes fresh context while retaining summaries by configured depth, and /reset archives the active conversation and starts a fresh one for the same stable session key. Use the smallest bump that matches this notable new behavior.
Align /new retention semantics with review feedback. When newSessionRetainDepth is -1, lossless-claw now leaves existing context_items untouched instead of dropping fresh-tail messages. Depth 0 remains the mode that drops only fresh-tail messages while keeping all summaries. Updated README, configuration docs, manifest help text, and lifecycle tests to match the behavior. Regeneration-Prompt: |\n Review feedback on PR #195 questioned whether the documented -1 /new retain depth should still drop fresh-tail messages. Keep the broader /new versus /reset lifecycle design intact, but make the narrow semantic change that -1 becomes a true no-op from lossless-claw's perspective by preserving all existing context items. Preserve 0 as the mode that drops only fresh-tail messages while keeping all summaries, then update docs and focused lifecycle tests so the distinction is explicit and verified.
Remove duplicate keys and an accidentally duplicated newSessionRetainDepth block introduced while resolving the rebase onto origin/main. This restores the intended config shape and keeps the config/plugin registration tests aligned with the rebased defaults and the PR's new session-retention setting. Regeneration-Prompt: | Rebase the PR branch onto the latest origin/main without losing the /new versus /reset lifecycle changes or the later comment-driven -1 retention semantics. During conflict resolution, preserve origin/main's newer defaults and fields while keeping the PR's newSessionRetainDepth support. After the rebase, inspect the resulting config and tests for any duplicate keys or duplicated property blocks caused by manual merges, fix those artifacts, and rerun the focused validation suite.
7568f5a to
59d121f
Compare
This was referenced Apr 1, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implement the Lossless Claw
/newversus/resetsession lifecycle spec so/newtrims context on the active conversation while/resetarchives the current conversation and starts a fresh active conversation for the same stable session key.Why
OpenClaw needs distinct semantics for starting a fresh thread versus clearing the current one, and the existing globally unique
session_keyschema made archival resets impossible without losing stable session identity and history.Changes
before_resetlifecycle handling/newretain depthTesting
npx vitest run test/migration.test.ts test/regression-2026-03-17.test.ts test/config.test.ts test/plugin-config-registration.test.ts test/engine.test.ts -t "before_reset lifecycle|ConversationStore session reuse|registers before_reset|uses default retain depth|loads newSessionRetainDepth"