Skip to main content
Integrate Moss into Strands Agents as a search tool. The agent calls moss_search automatically when it needs to look something up — no retrieval glue code required.
Note: For a complete example, see the Strands Agents cookbook.

Why use Moss with Strands Agents?

Strands Agents exposes tools as first-class primitives. MossSearchTool wraps a Moss index as a Strands-compatible tool, so the agent decides when to retrieve — and gets answers back in under 10 ms.

Required tools

  • Moss account with project credentials
  • Python 3.10+
  • Model provider credentials — Strands Agents defaults to Amazon Bedrock. Configure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION, or pass a different model provider (see below).

Integration guide

1

Installation

pip install strands-agents-moss
2

Environment setup

export MOSS_PROJECT_ID=your_project_id
export MOSS_PROJECT_KEY=your_project_key
3

Create an agent with Moss search

import asyncio
import os
from strands import Agent
from strands_agents_moss import MossSearchTool

async def main():
    moss = MossSearchTool(
        project_id=os.getenv("MOSS_PROJECT_ID"),
        project_key=os.getenv("MOSS_PROJECT_KEY"),
        index_name="my-index",
    )
    await moss.load_index()

    agent = Agent(tools=[moss.tool])
    agent("What is your refund policy?")

asyncio.run(main())

Choosing a model provider

Strands defaults to Amazon Bedrock. To use a different provider, pass a model argument:
# Assumes you already created moss = MossSearchTool(...) and awaited moss.load_index()

# OpenAI
from strands.models.openai import OpenAIModel
agent = Agent(model=OpenAIModel("gpt-4o"), tools=[moss.tool])

# Anthropic
from strands.models.anthropic import AnthropicModel
agent = Agent(model=AnthropicModel("claude-sonnet-4-20250514"), tools=[moss.tool])
See the Strands model providers docs for all supported providers.

Multi-agent example

Moss tools compose with Strands’ agents-as-tools pattern:
import asyncio
from strands import Agent
from strands_agents_moss import MossSearchTool

async def main():
    moss = MossSearchTool(index_name="product-docs")
    await moss.load_index()

    researcher = Agent(
        system_prompt="You are a research assistant. Use moss_search to find information.",
        tools=[moss.tool],
    )

    orchestrator = Agent(
        system_prompt="You coordinate research tasks. Delegate questions to the researcher.",
        tools=[researcher.as_tool(
            name="researcher",
            description="A research assistant with access to the knowledge base",
        )],
    )

    orchestrator("Summarise our return and refund policies.")

asyncio.run(main())

Configuration

MossSearchTool

ParameterDefaultDescription
project_idMOSS_PROJECT_ID env varMoss project ID
project_keyMOSS_PROJECT_KEY env varMoss project key
index_name(required)Name of the Moss index to query
tool_namemoss_searchTool name exposed to the LLM
tool_description(auto-generated)Tool description exposed to the LLM
top_k5Number of results to retrieve per query
alpha0.8Blend: 1.0 = semantic only, 0.0 = keyword only
result_prefixRelevant knowledge base results:\n\nPrefix prepended to formatted results

Methods

MethodDescription
load_index()Async. Pre-load the Moss index — call once at startup
search(query)Async. Query Moss and return formatted results as a string
toolProperty. Returns the Strands-compatible tool to pass to Agent(tools=[...])