Seamless session continuity — pick up exactly where you left off.
The user should never feel they lost progress when a session ends. Every new session should feel like waking up from a nap, not amnesia.
On every new session startup, before doing anything else, pull recent conversation context so you're not starting blind.
sessions_list(kinds: ["main"], limit: 5, messageLimit: 3)
For each of the 3 most recent sessions (excluding current), grab the final conversation turns:
sessions_history(sessionKey: "<key>", limit: 15, includeTools: false)
Focus on the last ~10 user/assistant exchanges per session. Skip tool calls — you want the actual conversation flow.
Write the verbatim last 3 rounds (user message + assistant reply = 1 round) from each session into the snapshot file. This is the key difference from v1.1 — not a summary, but actual conversation text so you can see exactly what was said:
# Session Relay — Conversation Context
> Generated: {timestamp}
> Sources: last 3 sessions
## 📎 Last Session Conversation Tail ({session_key}, {date})
**[User]** 能不能做到把最近的三段会话内容直接继承过来
**[Assistant]** 好想法,利用 sessions_list + sessions_history 直接拉...
**[User]** 我说的是上一次会话中的几轮对话接续
**[Assistant]** 啊明白了,你说的不是拉历史做摘要,而是把上个session最后几轮实际对话...
## 📎 Session -2 Conversation Tail ({session_key}, {date})
{same format, last 3 rounds}
## 📎 Session -3 Conversation Tail ({session_key}, {date})
{same format, last 3 rounds}
## 📋 Carry-Forward State
{Merged from conversation context + existing snapshot}
- Active work: ...
- Key decisions: ...
- Pending: ...
Now you've literally "seen" what was discussed. When the user talks to you:
Rules:
sessions_list/sessions_history fails, proceed normallyAfter completing significant work (file edits, multi-step tasks, key decisions), check context usage via session_status.
| Usage | Action |
|---|---|
| ------- | -------- |
| < 60% | No action |
| 60-75% | 🟡 Warm: Start incremental snapshot — append new progress to memory/relay-snapshot.md |
| 75-85% | 🟠 Hot: Full snapshot refresh — rewrite snapshot with complete current state |
| > 85% | 🔴 Critical: Force-save + warn user + sync to daily log |
Begin incremental saves at 60% so the snapshot stays fresh throughout the session.
Snapshot file: {workspace}/memory/relay-snapshot.md
❌ Bad — too abstract:
- [x] NuwaAI Demo — Codex generated index.html
✅ Good — actionable detail:
- [x] NuwaAI Demo — `nuwa-demo/index.html` generated by Codex
- Serves via `python3 -m http.server 8082`
- Uses NuwaAI WebSocket API, needs API key in page
- NOT YET TESTED — next step is open browser and verify connection
# Session Relay Snapshot
> Auto-saved by session-relay | {ISO-8601 timestamp}
> Model: {model} | Context: {used}/{max} ({pct}%)
> Session duration: ~{minutes} min | Compactions: {count}
## 🔥 In Progress (was actively working on this)
{What you were literally doing when the snapshot was taken.
Be specific: file paths, commands run, error states, next immediate step.}
## ✅ Completed This Session
- {Task}: {outcome + key file paths}
## 📋 Pending / Next Steps (priority order)
1. {Specific action} — {why, any blockers}
2. ...
## 🧠 Key Decisions & Context
- {Decision}: {rationale, so next session doesn't re-debate it}
## 🗂️ Working Files
{Files created/modified this session, with brief purpose}
- `path/to/file` — {what it is}
## 💬 User Preferences Discovered
{Anything learned about how the user likes to work}
## ⚠️ Gotchas & Warnings
{Things that tripped you up, so next session avoids them}
On new session startup:
memory/relay-snapshot.md — merge Phase 0 conversation tails with any saved snapshot dataWhen snapshot is consumed or user starts fresh:
# scripts/archive-snapshot.sh handles this
mkdir -p memory/relay-archive
mv memory/relay-snapshot.md memory/relay-archive/YYYY-MM-DD-HHMMSS.md
If the workspace uses HEARTBEAT.md for periodic checks:
```
# [AUTO] Session relay: context high, snapshot saved. Remove this line after reviewing.
```
Remove the HEARTBEAT line after a successful restore in the next session.
Every time a snapshot is saved, also append a summary to memory/YYYY-MM-DD.md:
### Session Relay Auto-Save ({HH:MM})
- Context at {pct}%
- Active: {one-line summary of in-progress work}
- Completed: {bullet list of done items}
This ensures the daily log captures progress even if the snapshot gets overwritten later.
When context exceeds 85%, append to EVERY reply:
---
⚠️ 上下文 {pct}%,建议 /compact 或 /new 开新会话。当前进度已自动保存。
sessions_list/sessions_history unavailable → skip Phase 0, fall back to snapshot file onlysession_status unavailable → skip monitoring, don't block userBe honest with users: session-relay is a best-effort bridge, not magic. Limitations:
session_status, monitoring thresholds won't triggerThe goal is: 80% continuity is infinitely better than 0%. Perfect continuity requires platform-level support.
共 1 个版本