Skip to content

Commit 3c4322a

Browse files
committed
Merge upstream changes to fix-retrieve-filter branch
2 parents ed24cb9 + b5e9ac2 commit 3c4322a

File tree

75 files changed

+3864
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3864
-472
lines changed

.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
python-version: '3.10'
6363
- name: Install dependencies
6464
run: |
65-
pip install --no-cache-dir hatch
65+
pip install --no-cache-dir -e ".[build]"
6666
- name: Run integration tests
6767
env:
6868
AWS_REGION: us-east-1

.github/workflows/test-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
python-version: ${{ matrix.python-version }}
6262
- name: Install dependencies
6363
run: |
64-
pip install --no-cache-dir hatch
64+
pip install --no-cache-dir -e ".[build]"
6565
- name: Run Unit tests
6666
id: tests
6767
run: hatch test tests --cover
@@ -114,7 +114,7 @@ jobs:
114114

115115
- name: Install dependencies
116116
run: |
117-
pip install --no-cache-dir hatch
117+
pip install --no-cache-dir -e ".[build]"
118118
119119
- name: Run lint
120120
id: lint

README.md

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Strands Agents Tools is a community-driven project that provides a powerful set
3838

3939
- 📁 **File Operations** - Read, write, and edit files with syntax highlighting and intelligent modifications
4040
- 🖥️ **Shell Integration** - Execute and interact with shell commands securely
41-
- 🧠 **Memory** - Store user and agent memories across agent runs to provide personalized experiences with both Mem0 and Amazon Bedrock Knowledge Bases
41+
- 🧠 **Memory** - Store user and agent memories across agent runs to provide personalized experiences with both Mem0, Amazon Bedrock Knowledge Bases, Elasticsearch, and MongoDB Atlas
4242
- 🕸️ **Web Infrastructure** - Perform web searches, extract page content, and crawl websites with Tavily and Exa-powered tools
4343
- 🌐 **HTTP Client** - Make API requests with comprehensive authentication support
4444
- 💬 **Slack Client** - Real-time Slack events, message processing, and Slack API access
@@ -146,6 +146,7 @@ Below is a comprehensive table of all available tools, how to use them with an a
146146
| use_computer | `agent.tool.use_computer(action="click", x=100, y=200, app_name="Chrome") ` | Desktop automation, GUI interaction, screen capture |
147147
| search_video | `agent.tool.search_video(query="people discussing AI")` | Semantic video search using TwelveLabs' Marengo model |
148148
| chat_video | `agent.tool.chat_video(prompt="What are the main topics?", video_id="video_123")` | Interactive video analysis using TwelveLabs' Pegasus model |
149+
| mongodb_memory | `agent.tool.mongodb_memory(action="record", content="User prefers vegetarian pizza", connection_string="mongodb+srv://...", database_name="memories")` | Store and retrieve memories using MongoDB Atlas with semantic search via AWS Bedrock Titan embeddings |
149150

150151
\* *These tools do not work on windows*
151152

@@ -886,6 +887,79 @@ result = agent.tool.elasticsearch_memory(
886887
)
887888
```
888889

890+
### MongoDB Atlas Memory
891+
892+
**Note**: This tool requires AWS account credentials to generate embeddings using Amazon Bedrock Titan models.
893+
894+
```python
895+
from strands import Agent
896+
from strands_tools.mongodb_memory import mongodb_memory
897+
898+
# Create agent with direct tool usage
899+
agent = Agent(tools=[mongodb_memory])
900+
901+
# Store a memory with semantic embeddings
902+
result = agent.tool.mongodb_memory(
903+
action="record",
904+
content="User prefers vegetarian pizza with extra cheese",
905+
metadata={"category": "food_preferences", "type": "dietary"},
906+
connection_string="mongodb+srv://username:[email protected]/?retryWrites=true&w=majority",
907+
database_name="memories",
908+
collection_name="user_memories",
909+
namespace="user_123"
910+
)
911+
912+
# Search memories using semantic similarity (vector search)
913+
result = agent.tool.mongodb_memory(
914+
action="retrieve",
915+
query="food preferences and dietary restrictions",
916+
max_results=5,
917+
connection_string="mongodb+srv://username:[email protected]/?retryWrites=true&w=majority",
918+
database_name="memories",
919+
collection_name="user_memories",
920+
namespace="user_123"
921+
)
922+
923+
# Use configuration dictionary for cleaner code
924+
config = {
925+
"connection_string": "mongodb+srv://username:[email protected]/?retryWrites=true&w=majority",
926+
"database_name": "memories",
927+
"collection_name": "user_memories",
928+
"namespace": "user_123"
929+
}
930+
931+
# List all memories with pagination
932+
result = agent.tool.mongodb_memory(
933+
action="list",
934+
max_results=10,
935+
**config
936+
)
937+
938+
# Get specific memory by ID
939+
result = agent.tool.mongodb_memory(
940+
action="get",
941+
memory_id="mem_1234567890_abcd1234",
942+
**config
943+
)
944+
945+
# Delete a memory
946+
result = agent.tool.mongodb_memory(
947+
action="delete",
948+
memory_id="mem_1234567890_abcd1234",
949+
**config
950+
)
951+
952+
# Use environment variables for connection
953+
# Set MONGODB_ATLAS_CLUSTER_URI in your environment
954+
result = agent.tool.mongodb_memory(
955+
action="record",
956+
content="User prefers vegetarian pizza",
957+
database_name="memories",
958+
collection_name="user_memories",
959+
namespace="user_123"
960+
)
961+
```
962+
889963
## 🌍 Environment Variables Configuration
890964

891965
Agents Tools provides extensive customization through environment variables. This allows you to configure tool behavior without modifying code, making it ideal for different environments (development, testing, production).
@@ -1024,6 +1098,7 @@ The Mem0 Memory Tool supports three different backend configurations:
10241098
| PYTHON_REPL_BINARY_MAX_LEN | Maximum length for binary content before truncation | 100 |
10251099
| PYTHON_REPL_INTERACTIVE | Whether to enable interactive PTY mode | None |
10261100
| PYTHON_REPL_RESET_STATE | Whether to reset the REPL state before execution | None |
1101+
| PYTHON_REPL_PERSISTENCE_DIR | Set Directory for python_repl tool to write state file | None |
10271102

10281103
#### Shell Tool
10291104

@@ -1117,6 +1192,19 @@ The Mem0 Memory Tool supports three different backend configurations:
11171192
| TWELVELABS_MARENGO_INDEX_ID | Default index ID for search_video tool | None |
11181193
| TWELVELABS_PEGASUS_INDEX_ID | Default index ID for chat_video tool | None |
11191194

1195+
#### MongoDB Atlas Memory Tool
1196+
1197+
| Environment Variable | Description | Default |
1198+
|----------------------|-------------|---------|
1199+
| MONGODB_ATLAS_CLUSTER_URI | MongoDB Atlas connection string | None |
1200+
| MONGODB_DEFAULT_DATABASE | Default database name for MongoDB operations | memories |
1201+
| MONGODB_DEFAULT_COLLECTION | Default collection name for MongoDB operations | user_memories |
1202+
| MONGODB_DEFAULT_NAMESPACE | Default namespace for memory isolation | default |
1203+
| MONGODB_DEFAULT_MAX_RESULTS | Default maximum results for list operations | 50 |
1204+
| MONGODB_DEFAULT_MIN_SCORE | Default minimum relevance score for filtering results | 0.4 |
1205+
1206+
**Note**: This tool requires AWS account credentials to generate embeddings using Amazon Bedrock Titan models.
1207+
11201208

11211209
## Contributing ❤️
11221210

0 commit comments

Comments
 (0)