feat(agent-memory): multitenancy via per-tenant bindings#232
Draft
cassiofariasmachado wants to merge 7 commits into
Draft
feat(agent-memory): multitenancy via per-tenant bindings#232cassiofariasmachado wants to merge 7 commits into
cassiofariasmachado wants to merge 7 commits into
Conversation
- create_client() and AgentMemoryClient.__init__ accept access_strategy (default SUBSCRIBER_ONLY) and tenant as constructor params - _resolve_tenant is now an instance method; per-call params override instance defaults - All method signatures change to Optional[AccessStrategy] = None (sentinel: use instance default) - user-guide: add client-level configuration section and PROVIDER_ONLY isolation warning - tests: update TestAccessStrategy and TestCreateClient for instance method
…for tenant isolation
- Add _load_config_for_instance(instance) to config.py — loads secrets
from /etc/secrets/appfnd/hana-agent-memory/{instance}/ following the
same pattern as the destination module
- Refactor AgentMemoryClient to maintain a per-tenant HttpTransport cache:
provider binding ('default') and subscriber bindings (one per tenant)
are each loaded into their own transport and lazily cached
- create_client() selects the initial binding based on access_strategy and
tenant, and wires config_loader for per-call tenant override support
- Integration test conftest now skips subscriber tests when the tenant
binding itself is not configured (not just the tenant name env var)
- Unit tests cover _load_config_for_instance, _get_transport routing,
per-call binding cache, and create_client() factory wiring
… warning - SUBSCRIBER_ONLY → SUBSCRIBER, PROVIDER_ONLY → PROVIDER across all agent_memory source, tests, feature files, and user guide - Add logger.warning() when AccessStrategy.PROVIDER is used, making the no-isolation behaviour explicit at runtime
NicoleMGomes
approved these changes
Jul 15, 2026
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.
Description
Adds multitenancy support to the
agent_memorymodule using a per-tenant binding approach. This is a temporary implementation while the Hana Agent Memory service does not yet support native multitenancy via token scoping.How it works
The runtime provisions one dedicated service instance per tenant and mounts its binding at:
/etc/secrets/appfnd/hana-agent-memory/default/— provider/etc/secrets/appfnd/hana-agent-memory/<tenant-subdomain>/— one per subscriber tenantInstead of deriving a subscriber token URL from the provider's binding (as in PR #222), this branch loads each tenant's own binding and creates a dedicated
HttpTransportper tenant, lazily cached.Public API
The public API is intentionally identical to PR #222 so that once the Agent Memory team adds native multitenancy, only the internal mechanics change — zero changes to caller code.
Code review changes
AccessStrategy.SUBSCRIBER_ONLY/PROVIDER_ONLYrenamed toSUBSCRIBER/PROVIDERfor brevitylogger.warning()emitted wheneverAccessStrategy.PROVIDERis resolved, making the no-isolation behaviour explicit at runtimeRelated Issue
N/A
Type of Change
How to Test
pytest tests/agent_memory/unit/— 260 tests passpytest tests/agent_memory/integration/— 14 pass, 12 skipChecklist
Breaking Changes
create_client()with no args raisesAgentMemoryConfigError(defaultSUBSCRIBERrequirestenant).Migration:
Additional Notes
_load_config_for_instance(instance)inconfig.pymirrors thedestinationmodule'sload_from_env_or_mount(instance)— uses the secret resolver with the tenant subdomain as the instance name.AgentMemoryClientholds_provider_transport+_subscriber_transport_cache(dict keyed by subdomain)._get_transport(strategy, tenant)selects the right transport per call.identityzonefield remains inAgentMemoryConfigfor forward compatibility with PR feat(agent-memory): add access_strategy and tenant params for multitenancy #222's token-URL-swap approach, but plays no role in this branch.AccessStrategy.PROVIDERemitslogger.warning()on every use to surface the no-isolation risk at runtime.