Skip to main content

Cloud-native LLM Agent Development and Testing Toolkit

Project description

Agent-Lab | 🤖🧪

Cloud-native framework for building, simulating and testing LLM agents

PyPI version Continuous Integration Quality Gate Coverage Python 3.12+ FastAPI License: MIT


Table of Contents


What is Agent-Lab?

Agent-Lab is a cloud-native Python framework for building, simulating and testing LLM agents on top of FastAPI, LangChain/LangGraph and PostgreSQL.

You pip install it as a library, define your agents by extending its base classes, and assemble a production-ready FastAPI application with a single create_app() call — no need to fork or edit the framework. Everything an agent needs is included: a REST API, an MCP server, relational and vector persistence, agent memory (LangGraph checkpoints), OpenTelemetry observability, and a batteries-included simulation and testing harness with LLM-as-judge evaluation.

Agent-Lab covers three things well:

  • 🏗️ Build — Define agents by subclassing WorkflowAgentBase (LangGraph state graphs) and registering them with a decorator. create_app() wires up the REST API, MCP server, persistence, auth and observability around them. Extend via subclassing and configuration, never by editing framework code.
  • 🧪 Simulate — Exercise agents end-to-end against live LLMs with conversational scenarios (a user simulator + judge agent) and dataset-driven experiments, scored by an LLM-as-judge and tracked over time in Langfuse and LangWatch.
  • ✅ Test — Validate every change with an integration suite that spins up real infrastructure (Postgres, Redis, Keycloak, embeddings, headless Chrome) via testcontainers.

The repository also ships a complete reference implementation — a standalone, deployable app with a set of ready-to-use agents (RAG, browser automation, voice memos, vision, multi-agent supervisors) — that doubles as a working example of how to consume the framework. See Reference Implementation.


Install

pip install btech-agent-lab

Requires Python 3.12+. Agents are served through FastAPI and persist to PostgreSQL (relational data, pgvector embeddings, and LangGraph checkpoints); see the Setup guide for provisioning those in development or production.


Quickstart

Define an agent, register it with a decorator, and build the FastAPI app around it:

# my_agents/echo.py
from langchain_core.messages import AIMessage
from langgraph.graph import MessagesState

from agent_lab import AgentBase, AgentUtils, discoverable_agent
from agent_lab.interface.api.messages.schema import Message, MessageRequest


@discoverable_agent("echo")
class EchoAgent(AgentBase):
    def __init__(self, agent_utils: AgentUtils):
        super().__init__(agent_utils)

    def create_default_settings(self, agent_id: str, schema: str):
        ...  # persist any per-agent settings on creation

    def get_input_params(self, message_request: MessageRequest, schema: str) -> dict:
        return message_request.to_dict()

    def process_message(self, message_request: MessageRequest, schema: str) -> Message:
        content, response_data = self.format_response(
            MessagesState(messages=[AIMessage(content=f"Echo: {message_request.message_content}")])
        )
        return Message(
            message_role="assistant",
            message_content=content,
            response_data=response_data,
            agent_id=message_request.agent_id,
        )
# app.py
from agent_lab import DEFAULT_SCAN_PACKAGES, create_app

# Scans your package for discoverable capabilities (agents, MCP tools,
# prompts, registrars) alongside the built-ins. The list replaces
# DEFAULT_SCAN_PACKAGES, so leave defaults out to exclude built-in
# capabilities you don't want.
app = create_app(scan_packages=[*DEFAULT_SCAN_PACKAGES, "my_agents"])
uvicorn app:app --reload

create_app() returns a standard FastAPI application: your agents are reachable over the REST API (/agents, /messages, ...), exposed through the MCP server at /mcp, and the interactive OpenAPI docs live at http://localhost:8000/docs.

Agents can also be published from an installed package via the agent_lab.agents entry point group, so consumers pick them up without listing scan_packages explicitly. See the Developer's Guide for extending configuration, the DI container, and routers.


How it works

Tech stack: Python 3.12, FastAPI, LangChain/LangGraph, PostgreSQL (3 databases: relational, vectors via pgvector, LangGraph checkpoints), Redis for pub/sub, Keycloak for auth, OpenTelemetry for observability.

Architecture — Clean Architecture with Dependency Injection:

  • Interface — FastAPI routers + MCP server
  • Services — Business logic, agent implementations
  • Domain — SQLAlchemy models, repository interfaces
  • Infrastructure — DB, auth, metrics (OpenTelemetry)

The public API — everything you need to consume Agent-Lab as a library is exported from the top-level agent_lab package and designed to be extended without editing framework code:

Export Purpose
create_app(...) Composition root — builds the FastAPI app from your agents, container, config and routers.
discoverable_agent Decorator that registers an AgentBase subclass under an agent_type.
AgentBase, WorkflowAgentBase, SupervisedWorkflowAgentBase, WebAgentBase, ContactSupportAgentBase Base classes to extend, from simple message handlers to multi-agent supervisors.
Container Subclass to add your own providers (services, MCP registrars, tracing backends).
ConfigSource, YamlConfigSource, VaultConfigSource Supply configuration from YAML, Vault, or a custom source.
RouterMount Mount extra FastAPI routers with their auth policy.
McpRegistrar Extend the MCP server with additional tools.

Agent system — Agents extend WorkflowAgentBase (which uses LangGraph state graphs). The hierarchy goes from simple (echo, adaptive RAG) to complex (coordinator-planner-supervisor multi-agent). Agents process messages, have configurable settings (Jinja2-templated prompts), and persist state in the checkpoints database. Registering an agent with @discoverable_agent makes it discoverable, resolvable through the DI container, and valid at the API — no manual registry or schema edits required.


Project Principles

  • Give researchers and developers a framework with everything they need to build, test, and experiment with LLM agents, plus ready-to-use reference implementations.
  • Extend through the public API — subclassing, decorators and configuration — never by editing framework code.
  • Expose an MCP server for agent discovery, conversation history, and agent-to-agent communication.
  • Ship with integration and simulation test suites so every agent change is validated automatically.
  • Provide full observability through logs, metrics, and traces for explainability and evaluation.
  • Run anywhere with a cloud-native architecture built for containerized deployment and horizontal scaling.

Key Features

  • Agent Framework: Build agents by extending base classes and assembling the app with create_app(); discover them via package scanning or entry points.
  • Agent Simulations: Evaluate agent behavior end-to-end with langwatch-scenario conversational simulations and dataset-driven experiments, scored by an LLM-as-judge and tracked in Langfuse and LangWatch. See the testing guide.
  • Integration Testing: Ensure reliability and correctness with a comprehensive integration test suite backed by testcontainers.
  • REST API: Manage integrations with AI suppliers, LLM settings, agents, and conversation histories through the built-in REST API.
  • MCP Server: Utilize the Model Context Protocol (MCP) server for agent discovery, dialog history, and agent-to-agent communication.
  • Observability: Obtain detailed insights through logs, metrics, and traces powered by OpenTelemetry, with reference implementations for Grafana and OpenSearch Dashboards.
  • Relational Persistence: Store data reliably using PostgreSQL to support the entity domain model for prompts, agent-specific settings, conversations, and more.
  • Secrets Management: Securely store and retrieve secrets with Vault.
  • Vector Storage and Search: Efficiently manage vector data using PgVector for similarity search and retrieval.
  • Agent Memory: Use the PostgreSQL checkpointer to store and retrieve agent memory, enabling agents to maintain context across interactions.
  • Cloud-Native: Optimized for cloud environments with Docker, Kubernetes, and Terraform scripts for streamlined deployment.

MCP Server

Agent-Lab features a MCP Server that allows agent discovery (get_agent_list tool), dialog history (get_message_list tool) and agent-to-agent communication (post_message tool).

The following example shows MCP Server discovering and obtaining dialog history of a supervised coder agent instance:

Claude Desktop Demo

Please refer to MCP guide for more details.

Note: Claude Desktop is used only for demonstration purposes. This project is not affiliated with Anthropic AI.


Reference Implementation

The repository ships a complete, deployable reference application (agent_lab.main) that registers every built-in agent — RAG, browser automation, voice memos, vision, and multi-agent supervisors. It's both a product you can run and the canonical example of how to consume the framework.

You can run it in two ways:

# As a standalone app (the reference implementation)
uvicorn agent_lab.main:app --reload
# Or with the bundled observability stack
docker compose -f compose-grafana.yml up --build      # Grafana
docker compose -f compose-opensearch.yml up --build    # OpenSearch Dashboards

It ships with Helm charts (charts/) for Kubernetes and Terraform scripts (terraform/) for provisioning cloud infrastructure — databases, auth realms, and secrets. See the Setup guide for details.

Agent-Lab is the generic base for downstream reference implementations. Only generic, reusable capabilities belong in the framework; product-specific agents and services live in the apps that consume it.


Documentation

Documentation is organized around how you use Agent-Lab:

  • Developer's Guide — for developers building agents and applications on Agent-Lab (as a library or in-repo): setup, the extension model, and development practices. See the Developer's Guide.
  • Researcher's Guide — for researchers running experiments: the MCP server, managing agents, tuning prompts, and prototyping new agents in Jupyter. See the Researcher's Guide.
  • Testing & Simulations — the integration and simulation suites and LLM-as-judge evaluation. See the testing guide.

Contributing

Community support is greatly appreciated. If you encounter any issues or have suggestions for enhancements, please report them by creating an issue on our GitHub Issues page.

Refer to our Developer's Guide for instructions on how to contribute to the project.


License

This project is licensed under the MIT License. See the LICENSE file for details.

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

btech_agent_lab-1.11.0.tar.gz (83.6 kB view details)

Uploaded Source

Built Distribution

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

btech_agent_lab-1.11.0-py3-none-any.whl (130.8 kB view details)

Uploaded Python 3

File details

Details for the file btech_agent_lab-1.11.0.tar.gz.

File metadata

  • Download URL: btech_agent_lab-1.11.0.tar.gz
  • Upload date:
  • Size: 83.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for btech_agent_lab-1.11.0.tar.gz
Algorithm Hash digest
SHA256 b8894fc36f03f22611d3d0bf1514161aa65843f9efe61f5885e51b826e1716bf
MD5 fab0a0bece09d5196acbfc0b4eae7fda
BLAKE2b-256 b4b0f65b82d0e55e80741a1334c8a1f7a0f93dc2fcbc9b7417f5a677c40a4800

See more details on using hashes here.

Provenance

The following attestation bundles were made for btech_agent_lab-1.11.0.tar.gz:

Publisher: pypi-publish.yml on btech-software/agent-lab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file btech_agent_lab-1.11.0-py3-none-any.whl.

File metadata

File hashes

Hashes for btech_agent_lab-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa440b086e66b5624e4c74c686fc52f739fce25a3dcb6aea96dd4a2f0b02ac4e
MD5 fbfb32819e536f1772918ffe717a64de
BLAKE2b-256 059119647b884fe7952655a1dd97649e88e5b1d085e092ea7b04c92e725a58c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for btech_agent_lab-1.11.0-py3-none-any.whl:

Publisher: pypi-publish.yml on btech-software/agent-lab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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