Skip to main content

Vital Agent Container Python SDK

Python 3.12+ License Code style: black

A Python SDK that provides infrastructure components for building AI agent applications with WebSocket-based communication and asynchronous message processing.

Features

  • 🚀 FastAPI-based WebSocket server with real-time communication
  • 🔄 Asynchronous message processing with task management
  • 🛡️ Production-ready with structured logging and health checks
  • 🔌 Plugin architecture for custom message handlers
  • ☁️ Cloud-ready with flexible deployment options
  • 📊 Streaming support for real-time data flows
  • Task cancellation and interruption handling

Installation

Install from PyPI (when published)

pip install vital-agent-container-sdk

Install from Source

Using Conda (Recommended for Development)

# Clone the repository
git clone https://github.com/vital-ai/vital-agent-container-python.git
cd vital-agent-container-python

# Create environment from environment.yml
conda env create -f environment.yml
conda activate vital-agent-container

# Install in development mode
pip install -e .

Using pip

# Clone the repository
git clone https://github.com/vital-ai/vital-agent-container-python.git
cd vital-agent-container-python

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .

Configuration

Option A: File-based configuration

  1. Copy the configuration template:

    cp agent_config.yaml.template agent_config.yaml
    
  2. Pass app_home when creating the app:

    app = AgentContainerApp(handler, app_home=".")
    

Option B: Programmatic configuration

Pass a config dict directly — no YAML file needed:

config = {"key": "value"}
app = AgentContainerApp(handler, app_config=config)

Environment variables

  1. Copy the environment template:

    cp .env.example .env
    
  2. Update the file with your specific configuration.

Usage

Basic Implementation

Create a custom message handler by implementing the AIMPMessageHandlerInf interface:

from vital_agent_container.handler.aimp_message_handler_inf import AIMPMessageHandlerInf
from vital_agent_container.agent_container_app import AgentContainerApp

class MyMessageHandler(AIMPMessageHandlerInf):
    async def process_message(self, config, client, websocket, data, started_event):
        # Your custom message processing logic here
        # Process the incoming message data
        message = json.loads(data)
        
        # Perform your agent logic
        response = await self.handle_agent_request(message)
        
        # Send response back through websocket
        await websocket.send_text(json.dumps(response))
        
        # Signal that processing has started
        started_event.set()
    
    async def handle_agent_request(self, message):
        # Implement your specific agent logic here
        return {"status": "processed", "result": "Agent response"}

# In your application's main module:
def create_agent_app():
    handler = MyMessageHandler()
    return AgentContainerApp(handler, app_home=".")

# Or pass configuration directly as a dict:
def create_agent_app_with_config():
    handler = MyMessageHandler()
    config = {"key": "value"}  # Your configuration dict
    return AgentContainerApp(handler, app_config=config)

# Your application can then run the agent container
if __name__ == "__main__":
    import uvicorn
    app = create_agent_app()
    uvicorn.run(app, host="0.0.0.0", port=8000)

Message Format

Applications using this library will receive messages in the following format through the WebSocket connection:

[{
  "type": "message",
  "http://vital.ai/ontology/vital-aimp#hasIntent": "process",
  "content": "Your message content"
}]

Your message handler implementation should parse and respond to these messages according to your agent's logic.

Development

Setup Development Environment

# Install with development dependencies
make install-dev

# Or manually
pip install -e ".[dev]"
pre-commit install

Available Make Commands

make help           # Show available commands
make test           # Run tests
make test-cov       # Run tests with coverage
make lint           # Run linting
make format         # Format code
make build          # Build package

Code Quality

This project uses:

  • Black for code formatting
  • isort for import sorting
  • flake8 for linting
  • mypy for type checking
  • pre-commit hooks for automated checks

API Endpoints

  • GET /health - Health check endpoint
  • WebSocket /ws - Main WebSocket endpoint for message processing

Architecture

├── vital_agent_container/
│   ├── agent_container_app.py      # Main FastAPI application
│   ├── handler/                    # Message handler interfaces
│   ├── processor/                  # Message processing logic
│   ├── tasks/                      # Task management
│   ├── streaming/                  # Streaming response handling
│   └── utils/                      # Utility functions
├── agent_config.yaml               # Agent configuration
├── environment.yml                 # Conda environment
└── pyproject.toml                  # Modern Python project config

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and add tests
  4. Run the test suite: make test
  5. Format your code: make format
  6. Submit a pull request

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

For questions and support, please open an issue on the GitHub repository.

Download files

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

Source Distribution

vital_agent_container_sdk-0.1.18.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

vital_agent_container_sdk-0.1.18-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file vital_agent_container_sdk-0.1.18.tar.gz.

File metadata

File hashes

Hashes for vital_agent_container_sdk-0.1.18.tar.gz
Algorithm Hash digest
SHA256 a42f814f1f46d3b3e76d9135b5c2b527fccf7b015b16e359ee71ea290b4be151
MD5 6fcd3bc7552c5e50be79dad56912fbe8
BLAKE2b-256 270396e33c53496ad039f93baf287de0908098d6c322b6305bcdb270a48f0b62

See more details on using hashes here.

File details

Details for the file vital_agent_container_sdk-0.1.18-py3-none-any.whl.

File metadata

File hashes

Hashes for vital_agent_container_sdk-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 92009f40ff1a98d27f897edd76abc9a625120ffa3c1e7a787b5ccc5e3ffda19c
MD5 44e38048a1b82ceaa237c998b9407422
BLAKE2b-256 8daa625c648f83ca7e0355c86e2ea81e83123cfc44018dfe2584e9c907dde84d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.18 This release

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page