openclaw - ✅(Solved) Fix Feature Request: Add /resume command to restore previous conversation context [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58028Fetched 2026-04-08 01:54:45
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1subscribed ×1

Add a /resume slash command that allows users to restore a previous conversation session, similar to the /resume command in Claude Code.

Root Cause

When a user runs /clear to reset the conversation context (e.g., because the context window got too long or the AI started getting confused), there is no way to restore the previous conversation. The JSONL session logs are still on disk, but there is no built-in mechanism to reload them into the active context.

PR fix notes

PR #36481: feat(session): add /resume command to list and restore previous sessions

Description (problem / solution / changelog)

feat(session): add /resume command to list and restore previous sessions

Summary

  • Add /resume command to list recent sessions or switch back to a previous one
  • Track session history on explicit reset (/new), daily/idle timeout, and /resume — each records the outgoing session with an auto-derived label
  • Auto-label uses: label → displayName → subject → last message preview from transcript
  • Restore logic: check live .jsonl paths first, then scan for .jsonl.reset.* archives (un-archiving the newest match)
  • List format: numbered index + 8-char ID + relative timestamp + label (e.g. 1. \aaaabbbb` 3h ago — help with TypeScript`)
  • Resume by index (/resume 1) or exact 8-char ID (/resume aaaabbbb)

Changes

  • types.ts: add SessionHistoryEntry type, history? field on SessionEntry, MAX_SESSION_HISTORY = 20
  • session-utils.fs.ts: add resolveSessionEntryLabel shared helper
  • session.ts: populate history on explicit reset and daily/idle expiry
  • commands-session-resume.ts: new command handler
  • commands-registry.data.ts + commands-core.ts: register /resume

Related Issues

  • #58028

Test plan

  • pnpm test — 138 tests pass
  • /resume with no history → "No previous sessions found."
  • /resume with history → numbered list with timestamps and labels
  • /resume 1 → resumes first entry by index
  • /resume aaaabbbb → resumes by 8-char ID
  • /resume after daily/idle reset → expired session appears in list
  • label auto-populated from last message preview when not explicitly set

Changed files

  • docs/tools/slash-commands.md (modified, +1/-0)
  • src/auto-reply/command-status-builders.ts (modified, +1/-1)
  • src/auto-reply/commands-registry.shared.ts (modified, +15/-0)
  • src/auto-reply/reply/commands-handlers.runtime.ts (modified, +2/-0)
  • src/auto-reply/reply/commands-session-resume.test.ts (added, +613/-0)
  • src/auto-reply/reply/commands-session-resume.ts (added, +328/-0)
  • src/auto-reply/reply/session.test.ts (modified, +117/-0)
  • src/auto-reply/reply/session.ts (modified, +30/-0)
  • src/config/sessions/types.ts (modified, +12/-0)
  • src/gateway/session-utils.fs.ts (modified, +27/-0)

Code Example

/resume              # Show recent sessions to pick from
/resume <sessionId>  # Resume a specific session
/resume last         # Resume the most recent cleared session
RAW_BUFFERClick to expand / collapse

Summary

Add a /resume slash command that allows users to restore a previous conversation session, similar to the /resume command in Claude Code.

Problem

When a user runs /clear to reset the conversation context (e.g., because the context window got too long or the AI started getting confused), there is no way to restore the previous conversation. The JSONL session logs are still on disk, but there is no built-in mechanism to reload them into the active context.

Currently, after /clear, the user loses all short-term context and must start fresh. Any important context must be manually reconstructed from memory files.

Proposed Solution

A /resume command that:

  1. Lists recent conversation sessions (with timestamps and token counts)
  2. Allows the user to pick a previous session to restore
  3. Reloads the selected session's context into the current conversation

Example usage:

/resume              # Show recent sessions to pick from
/resume <sessionId>  # Resume a specific session
/resume last         # Resume the most recent cleared session

Comparison with Claude Code

Claude Code has a /resume command that:

  • Lists previous sessions with dates and summaries
  • Lets users pick one to continue from where they left off
  • Restores the full conversation context

This is a very useful feature for long-running projects where context management is important.

Additional Context

  • Session logs are already persisted as JSONL files in ~/.openclaw/agents/<agentId>/sessions/
  • The session store (sessions.json) already tracks session metadata
  • This feature would complement the existing /clear and /compact commands

Thanks for considering this feature!

extent analysis

Fix Plan

To implement the /resume command, follow these steps:

  • Step 1: List recent conversation sessions
    • Read the sessions.json file to retrieve a list of recent sessions with timestamps and token counts.
    • Sort the sessions by timestamp in descending order.
  • Step 2: Handle /resume command
    • If no arguments are provided, display the list of recent sessions and prompt the user to pick one.
    • If a session ID is provided, resume the corresponding session.
    • If last is provided, resume the most recent cleared session.
  • Step 3: Reload session context
    • Read the JSONL file corresponding to the selected session.
    • Parse the JSONL file and restore the conversation context.

Example code (in Python):

import json
import os

# Load sessions from sessions.json
def load_sessions():
    with open('sessions.json', 'r') as f:
        return json.load(f)

# List recent sessions
def list_sessions(sessions):
    for session in sessions:
        print(f"{session['id']}: {session['timestamp']} ({session['token_count']} tokens)")

# Resume a session
def resume_session(session_id):
    # Load session logs from JSONL file
    session_logs = []
    with open(f"~/.openclaw/agents/<agentId>/sessions/{session_id}.jsonl", 'r') as f:
        for line in f:
            session_logs.append(json.loads(line))
    # Restore conversation context
    # ...

# Handle /resume command
def handle_resume(args):
    sessions = load_sessions()
    if not args:
        list_sessions(sessions)
        # Prompt user to pick a session
    elif args[0] == 'last':
        # Resume most recent cleared session
        resume_session(sessions[0]['id'])
    else:
        # Resume specific session
        resume_session(args[0])

Verification

To verify that the fix worked, test the /resume command with different scenarios:

  • Run /resume without arguments to list recent sessions.
  • Run /resume <sessionId> to resume a specific session.
  • Run /resume last to resume the most recent cleared session.
  • Verify that the conversation context is restored correctly.

Extra Tips

  • Make sure to handle errors and exceptions when loading and parsing session logs.
  • Consider implementing a limit on the number of recent sessions to display.
  • Add documentation and tests for the new /resume command.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Feature Request: Add /resume command to restore previous conversation context [1 pull requests, 1 participants]