You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add POST /api/v1/sessions/{session_id}/extract-preview to preview extracted memory candidates without writing memory files
expose the new capability through embedded and HTTP Python clients
document the new API in both English and Chinese session docs
add API / SDK regression tests for the preview flow
Why
OpenViking positions itself as an observable context database, but today session memory extraction is still mostly a black box: developers can commit and inspect the final result after writes, yet they cannot easily inspect what the extraction stage would produce before persistence.
This feature fills that gap by returning:
current live message count and estimated tokens
the latest completed archive overview used as extraction context
an archive summary preview for the current live messages
raw extracted candidate memories grouped by category
That makes memory debugging, prompt iteration, and agent integration much easier without mutating storage.
API
New endpoint:
POST /api/v1/sessions/{session_id}/extract-preview
ad hoc ASGI script validation for POST /api/v1/sessions/{session_id}/extract-preview
ad hoc AsyncHTTPClient.preview_memory_extraction() validation against a live uvicorn server
Notes
I also added pytest coverage for the new API and SDK path, but full local pytest execution is currently blocked by an environment-specific pytest-asyncio collection bug (AttributeError: 'Package' object has no attribute 'obj') in this machine's setup.
The new preview endpoint returns the result directly without using _to_jsonable, which could cause JSON serialization failures if latest_archive_overview or other result fields are not JSON-serializable. This is inconsistent with other endpoints like extract_session which use _to_jsonable.
Apply _to_jsonable to the result before returning it in the response, matching the pattern used in the extract_session endpoint. This ensures consistent JSON serialization of the response payload and avoids potential errors with non-serializable objects.
result = await service.sessions.preview_extract(session_id, _ctx)
-return Response(status="ok", result=result)+return Response(status="ok", result=_to_jsonable(result))
Suggestion importance[1-10]: 8
__
Why: The suggestion ensures consistent JSON serialization with the existing extract_session endpoint, preventing potential runtime errors from non-serializable objects in the response.
Updated based on the review suggestion. The extract-preview response now goes through , and I added a regression test to cover serialization of custom result objects.
Updated based on the review suggestion. The extract-preview response now goes through _to_jsonable, and I added a regression test to cover serialization of custom result objects.
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
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.
Summary
POST /api/v1/sessions/{session_id}/extract-previewto preview extracted memory candidates without writing memory filesWhy
OpenViking positions itself as an observable context database, but today session memory extraction is still mostly a black box: developers can commit and inspect the final result after writes, yet they cannot easily inspect what the extraction stage would produce before persistence.
This feature fills that gap by returning:
That makes memory debugging, prompt iteration, and agent integration much easier without mutating storage.
API
New endpoint:
POST /api/v1/sessions/{session_id}/extract-previewReturned payload includes:
session_idmessage_countestimated_message_tokenslatest_archive_overviewarchive_summary_previewcounts_by_categorycandidatesValidation
python3 -m py_compile openviking/session/compressor.py openviking/service/session_service.py openviking/server/routers/sessions.py openviking/client/local.py openviking/async_client.py openviking/sync_client.py openviking_cli/client/base.py openviking_cli/client/http.py openviking_cli/client/sync_http.py tests/server/test_api_sessions.py tests/server/test_http_client_sdk.pyPOST /api/v1/sessions/{session_id}/extract-previewAsyncHTTPClient.preview_memory_extraction()validation against a live uvicorn serverNotes
I also added pytest coverage for the new API and SDK path, but full local pytest execution is currently blocked by an environment-specific
pytest-asynciocollection bug (AttributeError: 'Package' object has no attribute 'obj') in this machine's setup.