heimdall systems.

Pattern

Claude agents and tenant isolation

Give an agent a tool and you must decide where the customer boundary lives. Why tenant ID shouldn't be a tool argument, with runnable examples.

In a multi-tenant product, every customer's documents, memory and cached answers sit on shared infrastructure. When an agent calls a tool such as "read memory" or "search our policies", that tool must only ever touch the current customer's data.

The tempting design passes the tenant ID as a tool argument. But tool arguments come from the model, and the model reads whatever is in the prompt. If a prompt can say "use tenant_id=other", the boundary is only as strong as the model's judgement.

A different design

Our examples use Anthropic's Claude Agent SDK with Ten-Grd, and move the boundary out of the model's reach:

The tool is short, because the tenant is bound outside it:

def tools_for(context):
    @tool("search_policy", "Search this customer's policies.", {
        "type": "object", "properties": {"topic": {"type": "string", "enum": ["refunds"]}},
        "required": ["topic"], "additionalProperties": False})
    async def search_policy(args):
        ...
        with tenant_scope(context):
            hits = docs.search(REFUNDS, predicate=Eq("topic", args["topic"]), limit=3)

Check it without a model

Each example runs offline first, with no API key, so you can check the boundary before spending a token:

git clone https://github.com/heimdallsystems/ten-grd-examples.git
cd ten-grd-examples
python -m pip install -r requirements.txt
python -m claude_agents.memory_agent
python -m claude_agents.rag_agent

The RAG check confirms that another tenant's document, a closer vector match to the question, is excluded. The memory check reads the same record ID under two tenants and rejects an injected tenant_id. A pass means these deterministic tool checks succeeded, not that a live model ran.

What we ran

We ran both offline checks on 2 November 2026 at the commit linked below, and both passed. A live run of the RAG agent with Claude for two tenants was recorded on 24 October 2026, and each agent answered only from its own tenant's documents. We have not recorded a live run of the memory agent.

What this doesn't do

Ten-Grd doesn't prevent prompt injection, check the model's answers, or replace authentication and authorization. It makes one property checkable: on guarded paths, the data a tool selects belongs to the tenant your host authenticated. To learn the SDK step by step, start with Ten-Grd: guard your agent's data.

← All research