Skip to content

fix(reflection): retain the runtime store for local execution - #195

Draft
hylin (linhongyu510) wants to merge 1 commit into
langchain-ai:mainfrom
linhongyu510:fix/reflection-runtime-store
Draft

hylin (linhongyu510) wants to merge 1 commit into
langchain-ai:mainfrom
linhongyu510:fix/reflection-runtime-store

Conversation

@linhongyu510

Copy link
Copy Markdown

When ReflectionExecutor(reflector) is used inside @entrypoint(store=store), submit() resolves the runtime store but leaves self._store as None. The background worker then overwrites the runtime's store with None, so memory writes fail. Synchronous and asynchronous executor searches fail for the same reason.

Fixes #194.

Retain the resolved store inside the existing double-checked lock before enqueueing. The worker and search methods then use the same store, as they already do for an explicit constructor store.

Adds eight behavioral cases using a real InMemoryStore and LangGraph entrypoint:

  • Runtime store reaches the background reflector and receives its write.
  • Synchronous and asynchronous searches return stored memory.
  • Later submissions reuse the initialized store without another runtime context.
  • An explicit constructor store retains precedence over a different runtime store.
  • Missing runtime/store configurations reject submission, and a later valid submission can recover.

Validation on Python 3.12.13 / LangGraph 1.2.14:

  • Unchanged main with the new tests: 5 failed, 3 passed. Failures are the missing worker/search store and failed reuse/recovery.
  • python -m pytest tests/test_reflection_store.py tests/short_term -q: 38 passed.
  • Changed-file Ruff lint and formatting checks, and git diff --check: passed.

One pre-existing trustcall deprecation warning appears on both versions. Provider-backed documentation examples were not run; these tests require no model API or external database.

Production scope is one assignment in LocalReflectionExecutor.submit(). This does not change cancellation handling, the remote executor or any public API. The existing lifetime model still binds one store per local executor.

Prepared with AI assistance. The validation above was executed locally.

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.

LocalReflectionExecutor drops the store injected by a LangGraph entrypoint

1 participant