Skip to content

fix(agentmain): make /resume fall back to L4 archives (v2, re-roll onto current main)#704

Open
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-630-resume-l4-fallback-v2
Open

fix(agentmain): make /resume fall back to L4 archives (v2, re-roll onto current main)#704
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-630-resume-l4-fallback-v2

Conversation

@Kailigithub

Copy link
Copy Markdown
Contributor

Summary

Extend the /resume slash command prompt so the agent falls back to L4 archive artifacts (all_histories.txt, {YYYY-MM}.zip in memory/L4_raw_sessions/) when fewer than 5 raw .txt files remain in temp/model_responses/.

Problem

memory/L4_raw_sessions/compress_session.py archives raw session .txt files once it merges them into all_histories.txt and the monthly {YYYY-MM}.zip archives. The /resume handler in agentmain.py hardcoded the prompt to read temp/model_responses/ only — so users who ran /resume after L4 archival completed saw an empty session list, even though their history was recoverable from the archives.

Fix

Single-source change in agentmain.py: extend the /resume prompt so the agent first tries temp/model_responses/ (live), and on <5 files remaining falls back to memory/L4_raw_sessions/all_histories.txt (consolidated history) or memory/L4_raw_sessions/{YYYY-MM}.zip (monthly archive).

if raw_query.strip() == '/resume':
    return (r'帮我看看最近有哪些会话可以恢复。'
            r'先列 temp/model_responses/ 目录(按修改时间取最近10个文件)。'
            r'如果该目录里的 .txt 少于 5 个(L4 归档已清理原始文件),'
            r'回退读 memory/L4_raw_sessions/all_histories.txt(汇总的会话历史),'
            r'或解压 memory/L4_raw_sessions/{YYYY-MM}.zip 取最近的月度归档。'
            r'从每个文件里找最后一个<history>...</history>块,'
            r'用一句话总结每个会话在聊什么,列表给我选。'
            r'注意读文件后要把字面的\n替换成真换行才能正确匹配。')

Verification

  • python3 -m py_compile agentmain.py — syntax OK
  • Regression harness at /tmp/test_issue_630.py — 4 checks:
    • test_old_prompt_gone: confirms the original /resume prompt string was removed.
    • test_new_prompt_present: confirms all_histories.txt, memory/L4_raw_sessions, {YYYY-MM}.zip, and 少于 5 个 (fallback threshold) are all present.
    • test_resume_branch_still_wired: confirms if raw_query.strip() == '/resume': is still in the file.
    • test_resume_returns_nonempty_string: confirms the return statement still starts with the resume directive.
  • Three-step dance (stash → test fails on main → pop → test passes with fix) confirms the test catches the regression.

Scope

The /resume handler hardcoded the prompt to read temp/model_responses/
but the archival pipeline in memory/L4_raw_sessions/compress_session.py
deletes the raw .txt files once it has merged them into
all_histories.txt and the monthly {YYYY-MM}.zip archives. The data is
still recoverable; the agent just isn't told to look for it.

Extend the /resume prompt so the agent falls back to the L4 archives
when fewer than 5 files remain in temp/model_responses/.

Re-roll of lsdefine#653 onto current main (original PR drifted into CONFLICTING
state at 23 days stale).

Closes lsdefine#630
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.

/resume 在 L4 会话归档后失效,无法感知已归档的历史会话

1 participant