Propagate request context through async task payloads#273
Merged
nicoloboschi merged 1 commit intomainfrom Feb 2, 2026
Merged
Conversation
The batch_retain and consolidation task handlers created internal RequestContext objects without tenant_id or api_key_id. This meant downstream operations (consolidation, mental model refreshes) triggered by async workers lost the original caller's request context. Fix by passing tenant_id and api_key_id through the task payload dict in submit_async_retain and submit_async_consolidation, then restoring them in the corresponding handlers (_handle_batch_retain, _handle_consolidation).
nicoloboschi
approved these changes
Feb 2, 2026
slayoffer
added a commit
to slayoffer/hindsight
that referenced
this pull request
Feb 3, 2026
Merged 7 upstream commits: - Fix: load operation validator extension in worker process (vectorize-io#280) - fix: custom pg schema is not reliable (vectorize-io#278) - feat(embed): add hindsight-embed profiles (vectorize-io#277) - feat: support for codex and claude-code as llm (vectorize-io#276) - feat: print version during startup (vectorize-io#275) - feat(openclaw): add llmProvider/llmModel plugin config options (vectorize-io#274) - Propagate request context through async task payloads (vectorize-io#273) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
tenant_idandapi_key_idthrough the task payload dict insubmit_async_retainandsubmit_async_consolidationRequestContextin the_handle_batch_retainand_handle_consolidationworker handlersContext
When async tasks were submitted, the worker handlers created
RequestContext(internal=True)without preserving the caller'stenant_idorapi_key_id. This meant any downstream operations that needed request context (e.g., extension hooks, mental model refreshes triggered after consolidation) could not identify the originating tenant.The
submit_async_consolidationandsubmit_async_refresh_mental_modelpaths already propagated this context correctly. This fix closes the gap forsubmit_async_retainand updates_handle_consolidationto also restore context from the payload.Test plan
submit_async_retainincludes_tenant_idand_api_key_idin task payload_handle_batch_retainrestores context from payloadsubmit_async_consolidationincludes_tenant_idand_api_key_idin task payload_handle_consolidationrestores context from payloaduv run pytest tests/ -v)