Skip to main content

Reusable infrastructure for building AI agents with Redis

Project description

Redis Agent Kit

Redis Agent Kit is an experimental Python library for building Redis-backed agent services. It provides durable task state, background workers, progress updates, streaming, memory hooks, RAG ingestion, and protocol adapters without requiring a specific LLM framework.

The project is early and under active development. APIs may change while the library settles.

What It Provides

  • Task lifecycle: create, queue, cancel, restart, inspect, and delete agent work.
  • Background execution: submit tasks from an API process and run them in independently scaled workers.
  • Agent context: pass a TaskContext with the user message, session, emitter, memory facade, attachments, and kit managers.
  • Progress updates: persist task milestones and optionally stream updates or tokens over Server-Sent Events.
  • RAG pipelines: prepare, chunk, embed, store, and search documents in Redis.
  • Protocol support: expose agents through REST, A2A, ACP, and MCP.

Installation

pip install "redis-agent-kit[api,cli]"

Optional extras:

pip install "redis-agent-kit[mcp]"       # MCP server
pip install "redis-agent-kit[memory]"    # working/long-term memory (Python 3.12 only)
pip install "redis-agent-kit[examples]"  # example app dependencies
pip install "redis-agent-kit[all]"       # all optional RAK features

Redis Agent Kit requires Python 3.11+ and Redis. Vector search requires Redis Stack or Redis 8.

Memory (agent-memory-server) requires Python 3.12. On other Python versions the memory extra is skipped; either run on 3.12, install with a slimmer extra (e.g. [api,cli]), or set RAK_MEMORY__ENABLED=false.

Quickstart

Start Redis:

docker run -d --name redis -p 6379:6379 redis:8

Create app.py:

from redis_agent_kit import AgentKit, EmitterMiddleware, TaskContext
from redis_agent_kit.api import create_app


async def my_agent(ctx: TaskContext) -> dict:
    await ctx.emitter.emit("Working...")
    return {"answer": f"Processed: {ctx.message}"}


kit = AgentKit(
    "redis://localhost:6379",
    agent_callable=my_agent,
    middleware=[EmitterMiddleware(start_message="Starting...")],
    queue_name="my_agent",
)

# Docket workers load an iterable task collection from module:path.
tasks = [kit.worker_task]

app = create_app(kit=kit)

Run the worker and API server in separate terminals:

rak worker --name my_agent --tasks app:tasks
uvicorn app:app --reload

Submit and inspect a task:

curl -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{"message": "What is Redis?"}'
{"task_id": "01J...", "session_id": "01J...", "status": "queued", "message": "Task created and queued for processing"}
curl http://localhost:8000/tasks/01J...

Task Handlers

New handlers should accept TaskContext:

async def handler(ctx: TaskContext) -> dict:
    await ctx.emitter.emit("Searching...")
    history = await ctx.memory.get_messages(limit=10)
    return {"response": f"{len(history)} previous messages"}

Legacy handlers with (task_id, session_id, message, context) are still accepted, but new code should prefer TaskContext.

Streaming

Use StreamConfig when clients need live task updates:

from redis_agent_kit import AgentKit, StreamConfig
from redis_agent_kit.api import create_app

stream_config = StreamConfig(enabled=True)

kit = AgentKit(
    "redis://localhost:6379",
    agent_callable=my_agent,
    stream_config=stream_config,
)
app = create_app(kit=kit, stream_config=stream_config)

Clients can connect to the per-task SSE endpoint:

const es = new EventSource(`/tasks/${taskId}/stream`);
es.addEventListener("update", (e) => console.log(JSON.parse(e.data).message));
es.addEventListener("token", (e) => process.stdout.write(JSON.parse(e.data).message));
es.addEventListener("done", (e) => {
  console.log(JSON.parse(e.data).result);
  es.close();
});

Inside a handler, use await ctx.emitter.emit(...) for persisted updates and await ctx.emitter.emit_token(...) for ephemeral token events.

Pipelines

Pipelines are included in the base package:

rak pipelines run ./docs --pattern "*.md" --chunk-size 800
rak pipelines status

The REST API also exposes pipeline endpoints under /pipelines. See the Pipelines guide for current request bodies and staged ingestion details.

Protocols

Use the REST app factory for standard HTTP plus optional A2A and ACP:

from redis_agent_kit import AgentCard, AgentManifest, Skill
from redis_agent_kit.api import create_app

agent_card = AgentCard(
    name="My Agent",
    description="Answers questions",
    url="http://localhost:8000",
    skills=[Skill(id="chat", name="Chat", description="General chat")],
)

agent_manifest = AgentManifest(
    name="my-agent",
    description="Answers questions",
)

app = create_app(
    kit=kit,
    enable_a2a=True,
    enable_acp=True,
    agent_card=agent_card,
    agent_manifest=agent_manifest,
)

Discovery endpoints:

  • A2A: GET /.well-known/agent.json
  • ACP: GET /agents
  • REST/OpenAPI: GET /docs

Documentation

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redis_agent_kit-0.3.0.tar.gz (553.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redis_agent_kit-0.3.0-py3-none-any.whl (140.8 kB view details)

Uploaded Python 3

File details

Details for the file redis_agent_kit-0.3.0.tar.gz.

File metadata

  • Download URL: redis_agent_kit-0.3.0.tar.gz
  • Upload date:
  • Size: 553.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for redis_agent_kit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b56944d06d789a760cf57c6635bc4933bd6e3be805b92e59d54e16076adbee90
MD5 4157b2a38b245612d84f13f6e64a9fa0
BLAKE2b-256 52f420b50c93343bde9b3c1c52814541e3a1553d3217f026d1d707140308d756

See more details on using hashes here.

File details

Details for the file redis_agent_kit-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for redis_agent_kit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26408d360be5ea8edc94bf72dc00318a170d152d7a98b859a5b1ed5451f7d7f9
MD5 a49c48d61f5968c0a5815caaab2d54ae
BLAKE2b-256 cef9265cc9a7dfc7f463d945c8808a9913d265c13eba4eaddd2e5dd2c7d693c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page