Skip to content

Commit 71df149

Browse files
committed
Deprecate --no-worker, add --task-backend
1 parent 634339f commit 71df149

File tree

8 files changed

+162
-97
lines changed

8 files changed

+162
-97
lines changed

Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
112112
# You may override with DISABLE_AUTH=true in development.
113113
ENV DISABLE_AUTH=false
114114

115-
# Default to development mode (no separate worker needed).
116-
# For production, override the command to remove --no-worker and run a separate task-worker container.
115+
# Default to development mode using the API's default backend (Docket). For
116+
# single-process development without a worker, add `--task-backend=asyncio` to
117+
# the api command.
117118
# Examples:
118-
# Development: docker run -p 8000:8000 redislabs/agent-memory-server
119+
# Development: docker run -p 8000:8000 redislabs/agent-memory-server agent-memory api --host 0.0.0.0 --port 8000 --task-backend=asyncio
119120
# Production API: docker run -p 8000:8000 redislabs/agent-memory-server agent-memory api --host 0.0.0.0 --port 8000
120121
# Production Worker: docker run redislabs/agent-memory-server agent-memory task-worker --concurrency 10
121-
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000", "--no-worker"]
122+
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]
122123

123124
# ============================================
124125
# AWS VARIANT - Includes AWS Bedrock support
@@ -142,10 +143,11 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
142143
# You may override with DISABLE_AUTH=true in development.
143144
ENV DISABLE_AUTH=false
144145

145-
# Default to development mode (no separate worker needed).
146-
# For production, override the command to remove --no-worker and run a separate task-worker container.
146+
# Default to development mode using the API's default backend (Docket). For
147+
# single-process development without a worker, add `--task-backend=asyncio` to
148+
# the api command.
147149
# Examples:
148-
# Development: docker run -p 8000:8000 redislabs/agent-memory-server:aws
150+
# Development: docker run -p 8000:8000 redislabs/agent-memory-server:aws agent-memory api --host 0.0.0.0 --port 8000 --task-backend=asyncio
149151
# Production API: docker run -p 8000:8000 redislabs/agent-memory-server:aws agent-memory api --host 0.0.0.0 --port 8000
150152
# Production Worker: docker run redislabs/agent-memory-server:aws agent-memory task-worker --concurrency 10
151-
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000", "--no-worker"]
153+
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ docker run -p 8000:8000 \
3434
redislabs/agent-memory-server:latest
3535
```
3636

37-
The default image runs in development mode (`--no-worker`), which is perfect for testing and development.
37+
The default image runs in development mode using the **asyncio** task backend (no separate worker required), which is perfect for testing and development.
3838

3939
**Production Deployment**:
4040

@@ -74,8 +74,8 @@ uv install --all-extras
7474
# Start Redis
7575
docker-compose up redis
7676

77-
# Start the server (development mode)
78-
uv run agent-memory api --no-worker
77+
# Start the server (development mode, default asyncio backend)
78+
uv run agent-memory api
7979
```
8080

8181
### 2. Python SDK
@@ -155,8 +155,8 @@ result = await executor.ainvoke({"input": "Remember that I love pizza"})
155155
# Start MCP server (stdio mode - recommended for Claude Desktop)
156156
uv run agent-memory mcp
157157

158-
# Or with SSE mode (development mode)
159-
uv run agent-memory mcp --mode sse --port 9000 --no-worker
158+
# Or with SSE mode (development mode, default asyncio backend)
159+
uv run agent-memory mcp --mode sse --port 9000
160160
```
161161

162162
### MCP config via uvx (recommended)

agent_memory_server/cli.py

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async def run_migration():
257257
)
258258
else:
259259
click.echo(
260-
"\nMigration completed with errors. " "Run again to retry failed keys."
260+
"\nMigration completed with errors. Run again to retry failed keys."
261261
)
262262

263263
asyncio.run(run_migration())
@@ -268,16 +268,41 @@ async def run_migration():
268268
@click.option("--host", default="0.0.0.0", help="Host to run the server on")
269269
@click.option("--reload", is_flag=True, help="Enable auto-reload")
270270
@click.option(
271-
"--no-worker", is_flag=True, help="Use FastAPI background tasks instead of Docket"
271+
"--no-worker",
272+
is_flag=True,
273+
help=(
274+
"(DEPRECATED) Use --task-backend=asyncio instead. "
275+
"If present, force FastAPI/asyncio background tasks instead of Docket."
276+
),
277+
deprecated=True,
278+
)
279+
@click.option(
280+
"--task-backend",
281+
default="docket",
282+
type=click.Choice(["asyncio", "docket"]),
283+
help=(
284+
"Background task backend (asyncio, docket). "
285+
"Default is 'docket' to preserve existing behavior using Docket-based "
286+
"workers (requires a running `agent-memory task-worker` for "
287+
"non-blocking background tasks). Use 'asyncio' (or deprecated "
288+
"--no-worker) for single-process development without a worker."
289+
),
272290
)
273-
def api(port: int, host: str, reload: bool, no_worker: bool):
291+
def api(port: int, host: str, reload: bool, no_worker: bool, task_backend: str):
274292
"""Run the REST API server."""
275293
from agent_memory_server.main import on_start_logger
276294

277295
configure_logging()
278296

279-
# Set use_docket based on the --no-worker flag
280-
if no_worker:
297+
# Determine effective backend.
298+
# - Default is 'docket' to preserve prior behavior (Docket workers).
299+
# - --task-backend=asyncio opts into single-process asyncio background tasks.
300+
# - Deprecated --no-worker flag forces asyncio for backward compatibility.
301+
effective_backend = "asyncio" if no_worker else task_backend
302+
303+
if effective_backend == "docket":
304+
settings.use_docket = True
305+
else: # "asyncio"
281306
settings.use_docket = False
282307

283308
on_start_logger(port)
@@ -298,9 +323,17 @@ def api(port: int, host: str, reload: bool, no_worker: bool):
298323
type=click.Choice(["stdio", "sse"]),
299324
)
300325
@click.option(
301-
"--no-worker", is_flag=True, help="Use FastAPI background tasks instead of Docket"
326+
"--task-backend",
327+
default="asyncio",
328+
type=click.Choice(["asyncio", "docket"]),
329+
help=(
330+
"Background task backend (asyncio, docket). "
331+
"Default is 'asyncio' (no separate worker needed). "
332+
"Use 'docket' for production setups with a running task worker."
333+
"(see `agent-memory task-worker`)."
334+
),
302335
)
303-
def mcp(port: int, mode: str, no_worker: bool):
336+
def mcp(port: int, mode: str, task_backend: str):
304337
"""Run the MCP server."""
305338
import asyncio
306339

@@ -317,10 +350,13 @@ def mcp(port: int, mode: str, no_worker: bool):
317350
from agent_memory_server.mcp import mcp_app
318351

319352
async def setup_and_run():
320-
# Redis setup is handled by the MCP app before it starts
321-
322-
# Set use_docket based on --no-worker flag
323-
settings.use_docket = no_worker
353+
# Configure background task backend for MCP.
354+
# Default is asyncio (no separate worker required). Use 'docket' to
355+
# send tasks to a separate worker process.
356+
if task_backend == "docket":
357+
settings.use_docket = True
358+
else: # "asyncio"
359+
settings.use_docket = False
324360

325361
# Run the MCP server
326362
if mode == "sse":

docker-compose-task-workers.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ networks:
1010

1111
services:
1212
# For testing a production-like setup, you can run this API and the
13-
# task-worker container. This API container does NOT use --no-worker, so when
14-
# it starts background work, the task-worker will process those tasks.
13+
# task-worker container. This API container uses --task-backend=docket, so
14+
# when it starts background work, the task-worker will process those tasks.
1515

1616
# =============================================================================
1717
# STANDARD (OpenAI/Anthropic only)
@@ -44,7 +44,7 @@ services:
4444
interval: 30s
4545
timeout: 10s
4646
retries: 3
47-
command: ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]
47+
command: ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000", "--task-backend", "docket"]
4848

4949
mcp:
5050
profiles: ["standard", ""]
@@ -64,7 +64,7 @@ services:
6464
- "9050:9000"
6565
depends_on:
6666
- redis
67-
command: ["agent-memory", "mcp", "--mode", "sse"]
67+
command: ["agent-memory", "mcp", "--mode", "sse", "--task-backend", "docket"]
6868
networks:
6969
- server-network
7070

@@ -126,7 +126,7 @@ services:
126126
interval: 30s
127127
timeout: 10s
128128
retries: 3
129-
command: ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]
129+
command: ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000", "--task-backend", "docket"]
130130

131131
mcp-aws:
132132
profiles: ["aws"]
@@ -151,7 +151,7 @@ services:
151151
- "9050:9000"
152152
depends_on:
153153
- redis
154-
command: ["agent-memory", "mcp", "--mode", "sse"]
154+
command: ["agent-memory", "mcp", "--mode", "sse", "--task-backend", "docket"]
155155
networks:
156156
- server-network
157157

docs/cli.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ agent-memory api [OPTIONS]
2727
- `--port INTEGER`: Port to run the server on. (Default: value from `settings.port`, usually 8000)
2828
- `--host TEXT`: Host to run the server on. (Default: "0.0.0.0")
2929
- `--reload`: Enable auto-reload for development.
30-
- `--no-worker`: Use FastAPI background tasks instead of Docket workers. Ideal for development and testing.
30+
- `--task-backend [asyncio|docket]`: Background task backend. `docket` (default) uses Docket-based background workers (requires a running `agent-memory task-worker` for non-blocking tasks). `asyncio` runs tasks inline in the API process and does **not** require a separate worker.
31+
- `--no-worker` (**deprecated**): Backwards-compatible alias for `--task-backend=asyncio`. Maintained for older scripts; prefer `--task-backend`.
3132

3233
**Examples:**
3334

3435
```bash
35-
# Development mode (no separate worker needed)
36-
agent-memory api --port 8080 --reload --no-worker
36+
# Development mode (no separate worker needed, asyncio backend)
37+
agent-memory api --port 8080 --reload --task-backend asyncio
3738

38-
# Production mode (requires separate worker process)
39+
# Production mode (default Docket backend; requires separate worker process)
3940
agent-memory api --port 8080
4041
```
4142

@@ -51,22 +52,22 @@ agent-memory mcp [OPTIONS]
5152

5253
- `--port INTEGER`: Port to run the MCP server on. (Default: value from `settings.mcp_port`, usually 9000)
5354
- `--mode [stdio|sse]`: Run the MCP server in stdio or SSE mode. (Default: stdio)
54-
- `--no-worker`: Use FastAPI background tasks instead of Docket workers. Ideal for development and testing.
55+
- `--task-backend [asyncio|docket]`: Background task backend. `asyncio` (default) runs tasks inline in the MCP process with no separate worker. `docket` sends tasks to a Docket queue, which requires running `agent-memory task-worker`.
5556

5657
**Examples:**
5758

5859
```bash
59-
# Stdio mode (recommended for Claude Desktop) - automatically uses --no-worker
60+
# Stdio mode (recommended for Claude Desktop) - default asyncio backend
6061
agent-memory mcp
6162

6263
# SSE mode for development (no separate worker needed)
63-
agent-memory mcp --mode sse --port 9001 --no-worker
64+
agent-memory mcp --mode sse --port 9001
6465

6566
# SSE mode for production (requires separate worker process)
66-
agent-memory mcp --mode sse --port 9001
67+
agent-memory mcp --mode sse --port 9001 --task-backend docket
6768
```
6869

69-
**Note:** Stdio mode automatically disables Docket workers as they're not needed when Claude Desktop manages the process lifecycle.
70+
**Note:** Stdio mode is designed for tools like Claude Desktop and, by default, uses the asyncio backend (no worker). Use `--task-backend docket` if you want MCP to enqueue background work into a shared Docket worker.
7071

7172
### `schedule-task`
7273

docs/getting-started.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ But you can also run these components via the CLI commands. Here's how you
2828
run the REST API server:
2929

3030
```bash
31-
# Development mode (no separate worker needed)
32-
uv run agent-memory api --no-worker
31+
# Development mode (no separate worker needed, asyncio backend)
32+
uv run agent-memory api --task-backend asyncio
3333

34-
# Production mode (requires separate worker process)
34+
# Production mode (default Docket backend; requires separate worker process)
3535
uv run agent-memory api
3636
```
3737

@@ -42,10 +42,10 @@ Or the MCP server:
4242
uv run agent-memory mcp
4343

4444
# SSE mode for development
45-
uv run agent-memory mcp --mode sse --no-worker
46-
47-
# SSE mode for production
4845
uv run agent-memory mcp --mode sse
46+
47+
# SSE mode for production (use Docket backend)
48+
uv run agent-memory mcp --mode sse --task-backend docket
4949
```
5050

5151
### Using uvx in MCP clients
@@ -80,7 +80,7 @@ Notes:
8080
uv run agent-memory task-worker
8181
```
8282

83-
**For development**, use the `--no-worker` flag to run tasks inline without needing a separate worker process.
83+
**For development**, the default `--task-backend=asyncio` on the `mcp` command runs tasks inline without needing a separate worker process. For the `api` command, use `--task-backend=asyncio` explicitly when you want single-process behavior.
8484

8585
**NOTE:** With uv, prefix the command with `uv`, e.g.: `uv run agent-memory --mode sse`. If you installed from source, you'll probably need to add `--directory` to tell uv where to find the code: `uv run --directory <path/to/checkout> run agent-memory --mode stdio`.
8686

docs/quick-start.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ EOF
7777
Start the REST API server:
7878

7979
```bash
80-
# Start the API server in development mode (runs on port 8000)
81-
uv run agent-memory api --no-worker
80+
# Start the API server in development mode (runs on port 8000, asyncio backend)
81+
uv run agent-memory api
8282
```
8383

8484
Your server is now running at `http://localhost:8000`!
@@ -307,7 +307,7 @@ For web-based MCP clients, you can use SSE mode, but this requires manually star
307307

308308
```bash
309309
# Only needed for SSE mode (development)
310-
uv run agent-memory mcp --mode sse --port 9000 --no-worker
310+
uv run agent-memory mcp --mode sse --port 9000
311311
```
312312

313313
**Recommendation**: Use stdio mode with Claude Desktop as it's much simpler to set up.
@@ -355,11 +355,11 @@ Now that you have the basics working, explore these advanced features:
355355

356356
## Production Deployment
357357

358-
The examples above use `--no-worker` for development convenience. For production environments, you should use Docket workers for better reliability, scalability, and performance.
358+
The examples above use asyncio task backends for simple, single-process development. For production environments, the `api` command defaults to the **Docket** backend (no flag needed), while the `mcp` command still defaults to **asyncio** for single-process MCP usage. Use `--task-backend=docket` with `mcp` when you want MCP to enqueue background work for workers.
359359

360360
### Why Use Workers in Production?
361361

362-
**Development mode (`--no-worker`):**
362+
**Development mode (asyncio backend):**
363363
- ✅ Quick setup, no extra processes needed
364364
- ✅ Perfect for testing and development
365365
- ❌ Tasks run inline, blocking API responses
@@ -375,10 +375,10 @@ The examples above use `--no-worker` for development convenience. For production
375375

376376
### Production Setup Steps
377377

378-
1. **Start the API server (without --no-worker):**
378+
1. **Start the API server (default Docket backend):**
379379

380380
```bash
381-
# Production API server
381+
# Production API server (uses Docket by default; requires task-worker)
382382
uv run agent-memory api --port 8000
383383
```
384384

@@ -396,8 +396,8 @@ uv run agent-memory task-worker --concurrency 5 &
396396
3. **Start MCP server (if using SSE mode):**
397397

398398
```bash
399-
# Production MCP server (stdio mode doesn't need changes)
400-
uv run agent-memory mcp --mode sse --port 9000
399+
# Production MCP server (uses Docket backend)
400+
uv run agent-memory mcp --mode sse --port 9000 --task-backend docket
401401
```
402402

403403
4. **Enable authentication:**
@@ -463,7 +463,7 @@ services:
463463
- "9000:9000"
464464
environment:
465465
- REDIS_URL=redis://redis:6379
466-
command: uv run agent-memory mcp --mode sse --port 9000
466+
command: uv run agent-memory mcp --mode sse --port 9000 --task-backend docket
467467
depends_on:
468468
- redis
469469

@@ -489,14 +489,14 @@ redis-cli -h localhost -p 6379
489489

490490
| Use Case | Mode | Command |
491491
|----------|------|---------|
492-
| **Quick testing** | Development | `uv run agent-memory api --no-worker` |
493-
| **Local development** | Development | `uv run agent-memory api --no-worker` |
492+
| **Quick testing** | Development | `uv run agent-memory api --task-backend asyncio` |
493+
| **Local development** | Development | `uv run agent-memory api --reload --task-backend asyncio` |
494494
| **Production API** | Production | `uv run agent-memory api` + workers |
495495
| **High-scale deployment** | Production | `uv run agent-memory api` + multiple workers |
496-
| **Claude Desktop MCP** | Either | `uv run agent-memory mcp` (stdio mode) |
497-
| **Web MCP clients** | Either | `uv run agent-memory mcp --mode sse [--no-worker]` |
496+
| **Claude Desktop MCP** | Either | `uv run agent-memory mcp` (stdio mode, asyncio backend) |
497+
| **Web MCP clients** | Either | `uv run agent-memory mcp --mode sse [--task-backend docket]` |
498498

499-
**Recommendation**: Start with `--no-worker` for development, then graduate to worker-based deployment for production.
499+
**Recommendation**: Start with the asyncio backend (`--task-backend asyncio`) for simple development runs, then rely on the default Docket backend for the API in production, and enable `--task-backend=docket` for MCP when you want shared workers.
500500

501501
## Common Issues
502502

@@ -513,8 +513,8 @@ redis-cli -h localhost -p 6379
513513
- If still failing, try: `uv add redisvl>=0.6.0`
514514

515515
**"Background tasks not processing"**
516-
- If using `--no-worker`: Tasks run inline, check API server logs
517-
- If using workers: Make sure task worker is running: `uv run agent-memory task-worker`
516+
- If using the asyncio backend: Tasks run inline, check API/MCP server logs
517+
- If using workers (`--task-backend docket` or API default in production): Make sure task worker is running: `uv run agent-memory task-worker`
518518
- Check worker logs for errors and ensure Redis is accessible
519519

520520
## Get Help

0 commit comments

Comments
 (0)