Skip to content

Commit 7efbe57

Browse files
committed
Add Docker Compose setup for Agent Memory Server
Added infrastructure to run Agent Memory Server for notebooks and CI: 1. docker-compose.yml: - Redis Stack (with RedisInsight) - Agent Memory Server with health checks 2. .env.example: - Template for required environment variables - OpenAI API key configuration 3. Updated README.md: - Comprehensive setup instructions - Docker Compose commands - Step-by-step guide for running notebooks 4. Updated CI workflow: - Start Agent Memory Server in GitHub Actions - Wait for service health checks - Set environment variables for notebooks - Show logs on failure for debugging This allows users to run 'docker-compose up' to get all required services, and CI will automatically start the memory server for notebook tests.
1 parent 0e71885 commit 7efbe57

File tree

4 files changed

+147
-12
lines changed

4 files changed

+147
-12
lines changed

.github/workflows/test.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ jobs:
8787

8888
services:
8989
redis:
90-
image: redis:8.0-M03
90+
image: redis/redis-stack:latest
9191
ports:
9292
- 6379:6379
93+
options: >-
94+
--health-cmd "redis-cli ping"
95+
--health-interval 10s
96+
--health-timeout 5s
97+
--health-retries 5
9398
9499
steps:
95100
- uses: actions/checkout@v3
@@ -99,6 +104,30 @@ jobs:
99104
with:
100105
python-version: ${{ env.PYTHON_VERSION }}
101106

107+
# Start Agent Memory Server
108+
- name: Start Agent Memory Server
109+
env:
110+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
111+
run: |
112+
docker run -d \
113+
--name agent-memory-server \
114+
--network host \
115+
-e REDIS_URL=redis://localhost:6379 \
116+
-e OPENAI_API_KEY=$OPENAI_API_KEY \
117+
-e LOG_LEVEL=info \
118+
redis/agent-memory-server:latest
119+
120+
# Wait for memory server to be ready
121+
echo "Waiting for Agent Memory Server to be ready..."
122+
for i in {1..30}; do
123+
if curl -f http://localhost:8000/health 2>/dev/null; then
124+
echo "Agent Memory Server is ready!"
125+
break
126+
fi
127+
echo "Waiting... ($i/30)"
128+
sleep 2
129+
done
130+
102131
- name: Create and activate venv
103132
run: |
104133
python -m venv venv
@@ -114,7 +143,14 @@ jobs:
114143
env:
115144
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
116145
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
146+
AGENT_MEMORY_URL: http://localhost:8000
147+
REDIS_URL: redis://localhost:6379
117148
run: |
118149
echo "Testing notebook: ${{ matrix.notebook }}"
119150
source venv/bin/activate
120151
pytest --nbval-lax --disable-warnings "${{ matrix.notebook }}"
152+
153+
- name: Show Agent Memory Server logs on failure
154+
if: failure()
155+
run: |
156+
docker logs agent-memory-server
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# OpenAI API Key (required for LLM operations)
2+
OPENAI_API_KEY=your-openai-api-key-here
3+
4+
# Redis Configuration
5+
REDIS_URL=redis://localhost:6379
6+
7+
# Agent Memory Server Configuration
8+
AGENT_MEMORY_URL=http://localhost:8000
9+
10+
# Optional: Redis Cloud Configuration
11+
# REDIS_URL=redis://default:password@your-redis-cloud-url:port
12+

python-recipes/context-engineering/README.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,47 @@ These modules are designed to be imported in notebooks and used as building bloc
8686

8787
## Getting Started
8888

89-
1. **Set up the environment**: Install required dependencies
90-
2. **Run the reference agent**: Start with the complete implementation
91-
3. **Explore the notebooks**: Work through the educational content
92-
4. **Experiment**: Modify and extend the agent for your use cases
89+
### Prerequisites
9390

94-
## Prerequisites
95-
96-
- Python 3.8+
97-
- Redis 8 (local or cloud)
91+
- Python 3.10+
92+
- Docker and Docker Compose (for running Redis and Agent Memory Server)
9893
- OpenAI API key
9994
- Basic understanding of AI agents and vector databases
10095

101-
## Quick Start
96+
### Quick Start
97+
98+
#### 1. Start Required Services
99+
100+
The notebooks and reference agent require Redis and the Agent Memory Server to be running:
101+
102+
```bash
103+
# Navigate to the context-engineering directory
104+
cd python-recipes/context-engineering
105+
106+
# Copy the example environment file
107+
cp .env.example .env
108+
109+
# Edit .env and add your OpenAI API key
110+
# OPENAI_API_KEY=your-key-here
111+
112+
# Start Redis and Agent Memory Server
113+
docker-compose up -d
114+
115+
# Verify services are running
116+
docker-compose ps
117+
118+
# Check Agent Memory Server health
119+
curl http://localhost:8000/health
120+
```
121+
122+
#### 2. Set Up the Reference Agent
102123

103124
```bash
104125
# Navigate to the reference agent directory
105-
cd python-recipes/context-engineering/reference-agent
126+
cd reference-agent
106127

107128
# Install dependencies
108-
pip install -r requirements.txt
129+
pip install -e .
109130

110131
# Generate sample course data
111132
python -m redis_context_course.scripts.generate_courses
@@ -117,6 +138,31 @@ python -m redis_context_course.scripts.ingest_courses
117138
python -m redis_context_course.cli
118139
```
119140

141+
#### 3. Run the Notebooks
142+
143+
```bash
144+
# Install Jupyter
145+
pip install jupyter
146+
147+
# Start Jupyter
148+
jupyter notebook notebooks/
149+
150+
# Open any notebook and run the cells
151+
```
152+
153+
### Stopping Services
154+
155+
```bash
156+
# Stop services but keep data
157+
docker-compose stop
158+
159+
# Stop and remove services (keeps volumes)
160+
docker-compose down
161+
162+
# Stop and remove everything including data
163+
docker-compose down -v
164+
```
165+
120166
## Learning Path
121167

122168
1. Start with **Section 1** notebooks to understand core concepts
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '3.8'
2+
3+
services:
4+
redis:
5+
image: redis/redis-stack:latest
6+
container_name: redis-context-engineering
7+
ports:
8+
- "6379:6379"
9+
- "8001:8001" # RedisInsight
10+
environment:
11+
- REDIS_ARGS=--save 60 1 --loglevel warning
12+
volumes:
13+
- redis-data:/data
14+
healthcheck:
15+
test: ["CMD", "redis-cli", "ping"]
16+
interval: 5s
17+
timeout: 3s
18+
retries: 5
19+
20+
agent-memory-server:
21+
image: redis/agent-memory-server:latest
22+
container_name: agent-memory-server
23+
ports:
24+
- "8000:8000"
25+
environment:
26+
- REDIS_URL=redis://redis:6379
27+
- OPENAI_API_KEY=${OPENAI_API_KEY}
28+
- LOG_LEVEL=info
29+
depends_on:
30+
redis:
31+
condition: service_healthy
32+
healthcheck:
33+
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
34+
interval: 10s
35+
timeout: 5s
36+
retries: 5
37+
start_period: 30s
38+
39+
volumes:
40+
redis-data:
41+

0 commit comments

Comments
 (0)