[Report] I Attended a Workshop on Learning the Basic Design of Multi-Tenant AI Agents with Kiro specs and Strands Agents #AWSreInvent #DVT337

[Report] I Attended a Workshop on Learning the Basic Design of Multi-Tenant AI Agents with Kiro specs and Strands Agents #AWSreInvent #DVT337

I attended a workshop at AWS re:Invent 2026 and learned the basics of building AI agents for multi-tenant SaaS! Introducing myself in English at my first session was the most nerve-racking part...
2026.12.01

This page has been translated by machine translation. View original

Introduction

Hello, this is Kanno from the Consulting Department, here at re:Invent.
Maybe because I couldn't sleep on the plane, I slept soundly on the day of arrival and have no jet lag, so I'm feeling great!

I attended a workshop at AWS re:Invent 2026 titled "Build a SaaS control plane with Kiro specs and Strands multi-tenant constructs (DVT337-R1)"! There was a self-introduction time at the start, and I was quite nervous speaking in broken English, but I'm sure my feelings got across... probably...

I'll quickly share an overview of the session and some points that might be useful!

Workshop Overview

  • Title: Build a SaaS control plane with Kiro specs and Strands multi-tenant constructs (DVT337-R1)
  • Level: 300 / Duration: about 60 minutes for Labs 1-3 (Lab 4 is optional, Lab 5 is for taking home)
  • Environment: Browser-based Kiro IDE on Workshop Studio and a temporary AWS account (us-east-1; event-only, no self-paced version)

The subject is a fictional customer support SaaS called "Unicorn Support", which is set to onboard its next 50 customers.
You build a setup where a single support AI agent safely handles inquiries from two companies on different plans (Acme on the standard plan and Globex on the premium plan).

The setup is a bit hard to follow, but it helps to understand it this way: you build one helper chatbot that references tenant information, selects what information to use per tenant, and makes sure tenants never get mixed up.

An operator creates tenants with the tenant API on the control plane, and the tenant state and configuration are stored. The support AI agent on the application plane receives inquiries from Acme and Globex users and references the tenant configuration with a read-only token

The flow of the Labs is as follows.

Lab What you do
Lab 1 Rewrite one requirement in the Spec, have Kiro implement it, and deploy with CDK
Lab 2 Register Acme and Globex via the API and compare the published configurations
Lab 3 Fix the hole that lets one tenant read another tenant's tickets, using the Spec
Lab 4 (optional) Fix the shared sandbox so it is created for each tool call
Lab 5 (optional) Start spec-driven development with the public reference

Design Points to Keep in Mind for SaaS AI Agent Development

Don't Make Adding Tenants a Manual Task

In Lab 1, you build a small control plane with API Gateway, Lambda, DynamoDB, and Parameter Store. When you call the tenant creation API, it finishes saving the configuration and the tenant becomes available.

An operator calls the tenant creation API on API Gateway, and Lambda runs the processing. After recording the tenant in DynamoDB and saving the configuration to Parameter Store, the status is updated to ACTIVE

If you resend the same content with the same client token, it returns the already-created tenant, and if only the plan (tier) is changed, it returns 409. The administrator's email is used only for provisioning and is designed not to appear in responses, public configuration, or logs.

This is more about multi-tenant implementation than AI agents, but it's important: idempotency and the line around personal information are hard to fix later, so it's essential to include them in the specification from the start.
Manually deploying tenants every time would be painful, so it's worth thinking carefully about an automation mechanism.

Change Per-Tenant Behavior Through Configuration

Behavior changes per Tier (the pricing structure of the service; you may be familiar with terms like Standard or Pro plans). Acme (standard) gets concise responses, while Globex (premium) gets urgent prioritization and follow-up suggestions. The definitions of this behavior and the system prompt are placed in Parameter Store, and we build a mechanism where the agent loads them from the API on every request.

When Requirement 3.3 in requirements.md is rewritten, Kiro updates the design and tasks and implements the code. It is reflected in the agent's replies through the deployed tenant configuration

Increasing the number of agents per tenant tends to break operations, so injecting only configuration into common code makes sense. I want to build it so it can respond as flexibly as possible.

In the session, Kiro did the implementation in this area: after modifying the design files and clicking a few buttons, it implemented things nicely. Very helpful.

Determine the Tenant from the Authenticated Identity

In the initial agent of Lab 3, if you ask as Alice from Acme, "Show me GLBX-3390," the Globex ticket is returned as is. Getting another tenant's information back is bad, isn't it...

A system prompt can't protect the access boundary, so it ends up relying on luck.
So we determine the tenant from the authenticated identity (TenantContext) and create tools fixed to that tenant for every request.
I think it's important to extract authenticated user information from the token and always use it, and never trust information sent from the user as is, such as the request body.

Before the fix, the tool searches tickets of all tenants with only the ticket ID, and the Globex ticket is returned. After the fix, the tool is bound to acme as determined by TenantContext, and GLBX-3390 returns no match

The implementation looks like this.

local_support_agent.py (excerpt after fix)
def build_ticket_tools(context: TenantContext) -> list[Any]:
    @tool(name="get_ticket")
    def get_ticket(ticket_id: str) -> str:
        # The tenant is passed from the authenticated context, not as an argument
        ticket = find_ticket(ticket_id, tenant_id=context.tenant_id)
        if ticket is None:
            return f"No authorised match for ticket {ticket_id.upper()}."
        return format_ticket(ticket)

    return [get_ticket]

def invoke_local(identity_name: str, conversation_id: str, prompt: str) -> dict[str, Any]:
    context = resolve_identity(identity_name, conversation_id)
    configuration = load_support_agent_configuration(context.tenant_id)
    agent = Agent(
        model=DeterministicTicketModel(behavior=configuration.behavior),
        tools=build_ticket_tools(context),
        system_prompt=configuration.system_prompt,
        callback_handler=None,
        agent_id=context.session_id,
    )
    ...

The only argument the model can pass to the tool is the ticket ID, so even if another tenant is written in the prompt, the search scope doesn't change. It's worth remembering to protect through code and tool design rather than through prompts. Let's protect what we want to protect through mechanisms like this!

Restrict Configuration Reads by Tenant Too

There are points to be careful about not only in the app but also in the infrastructure configuration.

After identifying the tenant from the authenticated identity, the agent issues a read-only token each time. This signed token contains the config-reader role and tenant_id, and the flow is to reference the configuration in Parameter Store via the API. Fixed tokens placed in environment variables or tenant names written in the prompt are not used.

However, just having a read-only role could allow someone to specify another tenant's URL and read another company's configuration. So verification is done in two stages: API Gateway and Lambda.

The agent references configuration with Acme's token. The authorizer checks the role and lets it through, and Lambda checks the tenant. Acme's configuration can be referenced, but Globex's configuration is stopped with a 403 before the storage is accessed

  • API Gateway authorizer
    • Only lets the operator role through for the admin API and only the config-reader role for the configuration read API. The authorizer for reading has its cache set to 0 seconds and verifies the token every time
  • Lambda for reading configuration
    • Matches the tenant_id signed in the token against the tenant in the URL. If they don't match, it returns 403 before reading DynamoDB or Parameter Store, so the caller can't even tell whether another tenant exists

With this two-stage verification, even if another tenant is specified, other companies' configuration can't be read, firmly prevented by the mechanism. We want to cover this with mechanisms and not rely only on implementation.

Separate the Code Execution Environment for Each Tool Call

In Lab 4, we add a tool that aggregates a CSV ticket list in a sandbox (a local substitute for AgentCore Code Interpreter). Initially, one sandbox was shared across all requests, so both companies' files remained and the sandbox was never stopped.
It would be awful if someone accessed the sandbox somehow and obtained another tenant's information...

Before the fix, acme-tickets.csv and globex-tickets.csv remain in a single sandbox that is never stopped. After the fix, a sandbox is created for each aggregation tool call by Acme and Globex, only tickets.csv is placed in it, and it is stopped when finished

code_sandbox_agent.py (excerpt after fix)
@tool(name="analyse_ticket_export")
def analyse_ticket_export() -> str:
    sandbox = start_session()
    try:
        sandbox.upload("tickets.csv", _authorised_export(context))
        try:
            result = sandbox.run_counts_by_priority("tickets.csv")
        except AnalysisError as error:
            return _encoded_analysis_error(error)
        return _encoded_analysis_result(
            sandbox.session_id,
            sandbox.list_files(),
            result,
        )
    finally:
        sandbox.stop()

So after the fix, the tool takes no arguments, creates a sandbox for each call, places the file under a fixed name (tickets.csv), and always stops it in finally. For tools that handle files, sharing makes it easy for other tenants' data to remain, so it's reassuring to design them to be created each time and reliably stopped.

The Public Repository It Was Based On

The public AWS reference that the workshop was based on contains eight multi-tenant AI agent samples.

https://github.com/aws-samples/sample-agentic-ai-acceleration-patterns

From users, through entry-point routing, to agent execution, where the agent handles memory isolation, code execution, and document ingestion. Tenant-aware tokens, tenant creation and placement, and usage metering are each also provided as samples

I think it's educational to take a look at this too! I'd like to dig deeper as well!

Conclusion

There wasn't much Strands-specific content and it was basic overall, but I felt it was a good refresher on the considerations when building a multi-tenant SaaS! Tenant permissions are something we want to handle strictly...!

Thank you for reading this article to the end!!


AWS re:Invent 2026まとめ情報

クラスメソッドは2026/11/30〜12/4にラスベガスで開催されるAWSカンファレンスイベント「re:Invent」を今年も特集しました。ぜひ一度ご覧ください。 re:Invent 2026ポータルサイトを見るAWS re:Invent公式サイトはこちら

Share this article

AWSのお困り事はクラスメソッドへ