Skip to content

feat: implement /new vs /reset session lifecycle semantics#195

Merged
jalehman merged 4 commits into
mainfrom
codex/lossless-claw-new-vs-reset
Apr 1, 2026
Merged

feat: implement /new vs /reset session lifecycle semantics#195
jalehman merged 4 commits into
mainfrom
codex/lossless-claw-new-vs-reset

Conversation

@jalehman

Copy link
Copy Markdown
Contributor

What

Implement the Lossless Claw /new versus /reset session lifecycle spec so /new trims context on the active conversation while /reset archives 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_key schema made archival resets impossible without losing stable session identity and history.

Changes

  • Add active and archived conversation state
  • Replace global session key uniqueness
  • Register before_reset lifecycle handling
  • Add configurable /new retain depth
  • Cover reset and pruning regressions
  • Document behavior and add changeset

Testing

  • 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"
  • Expected: focused migration, config, registration, and lifecycle tests pass

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.
jalehman added 4 commits April 1, 2026 12:56
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.
@jalehman jalehman force-pushed the codex/lossless-claw-new-vs-reset branch from 7568f5a to 59d121f Compare April 1, 2026 19:57
@jalehman jalehman merged commit 8efd2e9 into main Apr 1, 2026
2 checks passed
@jalehman jalehman deleted the codex/lossless-claw-new-vs-reset branch April 1, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant