| name | chat-records-recent-n |
| description | Return a reverse-chronological shortlist of recent conversation records (messages), not sessions. Use when the user asks for 最近N条交流记录/聊天记录, including records across historical sessions, then drill into any selected item. |
Chat Records Recent N
Generate a reverse-chronological list of recent records/messages across current + historical sessions.
Workflow
- Determine target count:
- If user specifies N (e.g., 30), use N.
- Otherwise default to 10.
- Collect historical sources first:
- Read
~/.openclaw/agents/main/sessions/sessions.json.
- Enumerate each
sessionFile (*.jsonl).
- Also read
workspace/memory/*.md as fallback when transcript files are missing/pruned/compacted.
- Extract recent records from each session file:
- Parse JSONL entries with
type=message and role user/assistant.
- Ignore pure metadata wrappers when possible (e.g.,
Conversation info ...).
- Keep timestamp + sessionId + brief text snippet.
- Extract fallback records from memory files:
- Prefer dated memory files like
memory/YYYY-MM-DD*.md.
- Parse conversation blocks (
[Fri ...], user:, assistant:) into record-like snippets.
- Mark source as
memory-summary when reconstructed from memory.
- Merge all records from transcripts + memory fallbacks.
- Sort by timestamp descending.
- Return top N records.
Output format
Return one numbered list, each item containing:
- Time (
YYYY-MM-DD HH:mm)
- SessionId (or key if available)
- Role (
user / assistant)
- 1-line snippet (<= 50 Chinese chars or <= 100 English chars)
Then add:
Rules
- This skill is record-level, not session-level.
- Respect user count exactly when possible (e.g., request 30 => return up to 30).
- If total records < requested count, return all and state actual count.
- Keep snippets factual; do not invent.
- Truncate long snippets with
….
Follow-up behavior
When user replies with a number:
- Locate that record (sessionId + timestamp).
- Load nearby context from same session (before/after several turns).
- Return a compact chronological excerpt.