Skip to content

feat: add cross-bank querying — multi-bank recall and reflect#578

Open
bjornslib wants to merge 1 commit intovectorize-io:mainfrom
bjornslib:pr/epic2-cross-bank-querying
Open

feat: add cross-bank querying — multi-bank recall and reflect#578
bjornslib wants to merge 1 commit intovectorize-io:mainfrom
bjornslib:pr/epic2-cross-bank-querying

Conversation

@bjornslib
Copy link
Contributor

Summary

  • CrossBankOrchestrator for querying across multiple memory banks in parallel
  • BudgetAllocator with equal/proportional/custom strategies for distributing query budget
  • Reciprocal Rank Fusion (k=60) for merging and deduplicating results across banks
  • Disposition reconciliation for multi-bank reflect (weighted average of bank traits)
  • HTTP endpoints: POST /v1/{tenant}/cross-bank/recall and /v1/{tenant}/cross-bank/reflect
  • MCP tools: cross_bank_recall, cross_bank_reflect
  • Comprehensive unit tests (1400+ lines)

Motivation

Currently each bank is an isolated memory store with no way to query across banks. Many use cases (multi-agent systems, federated knowledge) need to search and reason across multiple banks simultaneously while respecting per-bank dispositions and access controls.

New files

  • hindsight-api-slim/hindsight_api/engine/cross_bank.py — Orchestrator, allocator, fusion
  • hindsight-api-slim/hindsight_api/api/cross_bank_models.py — Pydantic request/response models
  • hindsight-api-slim/tests/test_cross_bank.py — Unit tests
  • hindsight-api-slim/tests/test_mcp_tools.py — MCP tool tests

Modified files

  • api/http.py — Two new cross-bank endpoints
  • api/mcp.py — Register cross-bank tools
  • engine/memory_engine.py — CrossBankOrchestrator property + initialization
  • mcp_tools.py — Cross-bank tool implementations

Test plan

  • Unit tests pass: uv run pytest tests/test_cross_bank.py tests/test_mcp_tools.py -v
  • Cross-bank recall returns fused results from multiple banks
  • Cross-bank reflect produces disposition-reconciled answers
  • Budget allocation respects per-bank minimums
  • No impact on existing single-bank operations

🤖 Generated with Claude Code

Add CrossBankOrchestrator for querying across multiple memory banks:
- BudgetAllocator with equal/proportional/custom strategies
- Reciprocal Rank Fusion (k=60) for merging results
- Disposition reconciliation for multi-bank reflect
- HTTP endpoints: POST /v1/{tenant}/cross-bank/recall and /reflect
- MCP tools: cross_bank_recall, cross_bank_reflect
- Comprehensive unit tests (1400+ lines)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bjornslib
Copy link
Contributor Author

Thought that supporting multiple banks when querying was important, as some questions will stretch across banks. I hope that this works fine with the new instances concept you introduced, likely for the Hindsight Cloud version.

Copy link
Collaborator

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cross-bank operations are really off of the current model in terms of security, quality, performance and general understanding of the project.

have you tried using tags to isolate data inside a single bank?

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.

2 participants