恢復正確 thread
Sessions 依 working directory 存在 ~/.grok/sessions。需要可重現性時用明確 ID resume;目前 directory 的任務毫無歧義時,才 continue 最近 session。
提供 --session-id 是建立 named headless session,不等於恢復既有 session。若需要新的 reasoning branch,又不想改變原 session,使用 --fork-session。
grok --resume <session-id>
grok --resume
grok -c
grok sessions list 在 context 反過來控制你之前管理它
用 /context 或 /session-info 查看 context window 壓力。/compact 可壓縮 history,並接受簡短 instruction,指定必須保留的 facts、constraints 或 decisions。
Compaction 是有損 summary boundary。優先保存 acceptance criteria、unresolved failures、current file state 與 verification commands,而不是所有對話岔路。
/context
/compact Preserve the accepted architecture, failing tests, and remaining verification steps. 先理解資料損失,再進行 recovery
/rewind 會把檔案恢復到選定 prompt snapshot,並截斷 conversation。官方指南警告,未 commit 到 git 的 reverted changes 會遺失,因此先檢查 status 並建立安全 checkpoint。
需要 audit trail 或 handoff 時,export Markdown transcript。Session storage 可能包含 prompt、tool output 與 snapshots,應依 repository 敏感度設定 retention 與 workstation access control。
- 使用 /rewind 前先檢查 git status。
- 不要把 session history 當成安全 secret store。
- 依 team policy 刪除或封存 sessions。
/rewind
grok export <session-id> session.md