feat(session): async commit, session metadata, and archive continuity threading#900
Merged
feat(session): async commit, session metadata, and archive continuity threading#900
Conversation
Session commit now returns immediately after archiving messages (Phase 1). Summary generation and memory extraction (Phase 2) run in the background via asyncio.create_task(), returning a task_id for polling progress. - Add get_task() API across all client layers for querying background task status - get_session() auto-creates session if it does not exist - Remove wait parameter and telemetry from commit endpoint - Add .done completion marker to archive directories - Update docs (EN/ZH) and tests for new two-phase flow
… get_session SessionService.get() now defaults to auto_create=False, raising NotFoundError for missing sessions. A new SessionMeta dataclass tracks created_at, updated_at, message_count, commit_count, memories_extracted (by category), last_commit_at, and cumulative llm_token_usage. Meta is persisted to .meta.json and updated on add_message, commit Phase 1 (message clear), and commit Phase 2 completion (token usage, memory counts via bind_telemetry). All client layers (local/async/sync/HTTP) and API docs updated accordingly.
|
Failed to generate code suggestions for PR |
Made-with: Cursor
Thread the latest completed archive overview into archive summary generation and memory extraction, and simplify search context assembly to current messages plus the latest archive overview. Co-Authored-By: Claude Opus 4.6
chenjw
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR reshapes the session commit flow around a strict two-phase model:
task_idOn top of the async commit split, this PR also makes session history usable as continuity context instead of isolated archive snapshots. The latest completed archive overview is threaded into both archive summary generation and memory extraction, and
get_context_for_search()now exposeslatest_archive_overviewplus current in-session messages. The structured summary prompt was updated accordingly so later archives can explicitly carry forward stable context, separate newly introduced information, and preserve continuity-relevant user quotes.This PR also adds persistent session metadata via
.meta.json, simplifies the session API surface, and updates client/example integrations and docs to the new task-based commit semantics.Related Issue
N/A
Type of Change
Changes Made
Session.commit_async():messages.jsonl, clears the active message buffer, persists updated metadata, and returns{ status: "accepted", task_id, archive_uri, archived }.donefinalization, and final metadata updates.meta.jsonviaSessionMeta, includingmessage_count,commit_count,memories_extracted,last_commit_at, and accumulated LLM token usageGET /sessions/{id}?auto_create=truesupport for lazy session creationget_task()and aligned sync/async/local clients with the new commit response shape/sessions/{id}/commitalways archives inline and returns a backgroundtask_id, while conflict protection is handled via task tracker checkslatest_archive_overview+current_messages)_get_latest_completed_archive_overview()to skip incomplete archives and only expose the newest completed overviewcompression/structured_summaryprompt so later archive overviews are continuity-aware and explicitly separate:Testing
Test coverage added/updated includes:
latest_archive_overviewinto summary generation and memory extractionChecklist
Screenshots (if applicable)
N/A
Additional Notes
Suggested reviewer focus:
get_sessionlatest_archive_overviewis the right abstraction for summary generation, extraction, and search context