Metadata-Version: 2.4
Name: redis-agent-kit
Version: 0.1.1
Summary: Reusable infrastructure for building AI agents with Redis
Project-URL: Homepage, https://github.com/redis-developer/redis-agent-kit
Project-URL: Documentation, https://github.com/redis-developer/redis-agent-kit#readme
Project-URL: Repository, https://github.com/redis-developer/redis-agent-kit
Project-URL: Issues, https://github.com/redis-developer/redis-agent-kit/issues
Author-email: Redis <oss@redis.com>
License: MIT License
        
        Copyright (c) 2026 Redis
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,ai,llm,rag,redis
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: httpx
Requires-Dist: litellm
Requires-Dist: pydantic-settings
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pydocket
Requires-Dist: python-ulid>=2.0.0
Requires-Dist: pyyaml
Requires-Dist: redis>=5.0.0
Requires-Dist: redisvl
Provides-Extra: all
Requires-Dist: agent-memory-server; (python_version >= '3.12' and python_version < '3.13') and extra == 'all'
Requires-Dist: click>=8.0.0; extra == 'all'
Requires-Dist: fastapi>=0.100.0; extra == 'all'
Requires-Dist: fastmcp>=3.0.0; extra == 'all'
Requires-Dist: nest-asyncio>=1.5.0; extra == 'all'
Requires-Dist: rich>=13.0.0; extra == 'all'
Requires-Dist: uvicorn>=0.20.0; extra == 'all'
Provides-Extra: api
Requires-Dist: fastapi>=0.100.0; extra == 'api'
Requires-Dist: uvicorn>=0.20.0; extra == 'api'
Provides-Extra: cli
Requires-Dist: click>=8.0.0; extra == 'cli'
Requires-Dist: nest-asyncio>=1.5.0; extra == 'cli'
Requires-Dist: rich>=13.0.0; extra == 'cli'
Provides-Extra: dev
Requires-Dist: agent-memory-server; (python_version >= '3.12' and python_version < '3.13') and extra == 'dev'
Requires-Dist: codespell<3,>=2.4.1; extra == 'dev'
Requires-Dist: fastmcp>=3.0.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: nest-asyncio>=1.5.0; extra == 'dev'
Requires-Dist: pre-commit>=4.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Requires-Dist: testcontainers[redis]>=4.0.0; extra == 'dev'
Provides-Extra: examples
Requires-Dist: click>=8.0.0; extra == 'examples'
Requires-Dist: fastapi>=0.100.0; extra == 'examples'
Requires-Dist: fastmcp>=3.0.0; extra == 'examples'
Requires-Dist: langchain-openai>=0.2.0; extra == 'examples'
Requires-Dist: langgraph>=0.2.0; extra == 'examples'
Requires-Dist: nest-asyncio>=1.5.0; extra == 'examples'
Requires-Dist: openai-agents>=0.0.3; extra == 'examples'
Requires-Dist: python-dotenv>=1.0.0; extra == 'examples'
Requires-Dist: rich>=13.0.0; extra == 'examples'
Requires-Dist: uvicorn>=0.20.0; extra == 'examples'
Provides-Extra: mcp
Requires-Dist: fastmcp>=3.0.0; extra == 'mcp'
Provides-Extra: memory
Requires-Dist: agent-memory-server; (python_version >= '3.12' and python_version < '3.13') and extra == 'memory'
Provides-Extra: pipelines
Description-Content-Type: text/markdown

# 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

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

Optional extras:

```bash
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:

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

Create `app.py`:

```python
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:

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

Submit and inspect a task:

```bash
curl -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{"message": "What is Redis?"}'
```

```json
{"task_id": "01J...", "session_id": "01J...", "status": "queued", "message": "Task created and queued for processing"}
```

```bash
curl http://localhost:8000/tasks/01J...
```

## Task Handlers

New handlers should accept `TaskContext`:

```python
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:

```python
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:

```js
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:

```bash
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](docs/guide/pipelines.md) for current request bodies and staged ingestion details.

## Protocols

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

```python
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

- [Tutorial](docs/tutorial.md)
- [Tasks](docs/guide/tasks.md)
- [Sessions](docs/guide/sessions.md)
- [Memory](docs/guide/memory.md)
- [Streaming](docs/guide/streaming.md)
- [Middleware](docs/guide/middleware.md)
- [Protocols](docs/guide/protocols.md)
- [Input Handling](docs/guide/input.md)
- [Pipelines](docs/guide/pipelines.md)
- [CLI](docs/guide/cli.md)
- [API](docs/guide/api.md)

## License

MIT
