Skip to content

[codex] Persist graph trace for context-only retrieval#3073

Open
shuzhouzhang wants to merge 1 commit into
topoteretes:devfrom
shuzhouzhang:codex/cognee-persist-context-trace
Open

[codex] Persist graph trace for context-only retrieval#3073
shuzhouzhang wants to merge 1 commit into
topoteretes:devfrom
shuzhouzhang:codex/cognee-persist-context-trace

Conversation

@shuzhouzhang

Copy link
Copy Markdown

Summary

  • add an opt-in persist_trace flag for context-only search and recall calls
  • persist retrieved graph element IDs to the session cache without generating an LLM completion
  • wire the flag through SDK/API/cloud-client paths and add focused unit coverage

Why

When only_context=True, Cognee skips completion generation. That also meant graph trace metadata was not saved, so later feedback/improve flows could not know which graph elements were used for the returned context.

Validation

  • .\.venv\Scripts\python -m pytest cognee\tests\unit\modules\retrieval\graph_completion_retriever_test.py cognee\tests\unit\modules\search\test_get_retriever_output.py -q
  • .\.venv\Scripts\python -m py_compile cognee\modules\retrieval\graph_completion_retriever.py cognee\modules\search\methods\get_retriever_output.py cognee\modules\search\methods\search.py cognee\api\v1\search\search.py cognee\api\v1\search\routers\get_search_router.py cognee\api\v1\recall\recall.py cognee\api\v1\recall\routers\get_recall_router.py cognee\api\v1\serve\cloud_client.py cognee\tests\unit\modules\retrieval\graph_completion_retriever_test.py cognee\tests\unit\modules\search\test_get_retriever_output.py
  • git diff --check

Fixes #2910

@github-actions

Copy link
Copy Markdown
Contributor

Hello @shuzhouzhang, thank you for submitting a PR! We will respond as soon as possible.

@shuzhouzhang shuzhouzhang marked this pull request as ready for review June 15, 2026 06:20
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.

1 participant