Skip to main content

Base agent class for all Beast Mode agents

Project description

Beast Agent

Base agent class for ALL Beast Mode agents

PyPI version Python Versions License: MIT Code style: black


🎯 Purpose

The foundational base class (BaseAgent) that EVERY Beast Mode agent inherits from.

This package provides:

  • ✅ Standardized agent lifecycle (startup, shutdown, health checks)
  • ✅ Message handling via beast-mailbox-core integration
  • ✅ Agent registration and discovery
  • ✅ Capability declaration and management
  • ✅ Optional logging/telemetry hooks
  • ✅ Configuration management

Architectural Clarity:

  • beast-agent = Low-level base class (every agent IS-A beast-agent)
  • beast-agentic-framework = High-level orchestration (multi-agent coordination)

🚀 Quick Start

Installation

pip install beast-agent

Create Your First Agent

from beast_agent import BaseAgent
from beast_agent.decorators import capability

class MyAgent(BaseAgent):
    """Simple agent with a single capability"""
    
    def __init__(self):
        super().__init__(
            agent_id="my-agent",
            capabilities=["process_data"]
        )
    
    @capability("process_data")
    async def process_data(self, data: dict) -> dict:
        """Process data and return results"""
        # Your agent logic here
        return {"status": "processed", "result": data}

# Run the agent
async def main():
    agent = MyAgent()
    await agent.startup()
    # Agent is now ready to handle messages
    
if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

📋 Agent Patterns

Per-Repo Agent Pattern

class RepoAgent(BaseAgent):
    """Agent that monitors a single repository"""
    
    def __init__(self, repo_name: str):
        super().__init__(
            agent_id=f"repo-agent-{repo_name}",
            capabilities=["code_review", "pr_validation", "security_scan"]
        )
        self.repo_name = repo_name
    
    @capability("code_review")
    async def review_code(self, pr_number: int) -> dict:
        """Review code in PR"""
        # Review logic
        return {"status": "reviewed", "pr": pr_number}

Per-Branch Agent Pattern

class BranchAgent(BaseAgent):
    """Agent specific to a branch"""
    
    def __init__(self, repo_name: str, branch_name: str):
        super().__init__(
            agent_id=f"branch-agent-{repo_name}-{branch_name}",
            capabilities=["deployment", "testing", "monitoring"]
        )
        self.repo = repo_name
        self.branch = branch_name
    
    @capability("deployment")
    async def deploy(self, environment: str) -> dict:
        """Deploy branch to environment"""
        # Deployment logic
        return {"status": "deployed", "environment": environment}

🔧 Features

Agent Lifecycle

agent = MyAgent()
await agent.startup()  # Initialize and register
# ... agent is running ...
await agent.shutdown()  # Graceful cleanup

Message Handling

# Register handler for message type
agent.register_handler("TASK_REQUEST", handle_task_request)

# Send message to another agent
await agent.send_message(
    target="other-agent-id",
    message_type="HELP_REQUEST",
    content={"task": "analyze_code"}
)

Health Checks

health = agent.health_check()
print(f"Healthy: {health.healthy}")
print(f"State: {health.state}")

📚 Documentation


🧪 Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=src/beast_agent --cov-report=html

# Run specific test
pytest tests/test_base_agent.py

# Run integration tests (requires Redis and beast-mailbox-core)
# Note: Integration tests are automatically skipped if dependencies unavailable
pytest tests/test_mailbox_integration.py

# Run all tests including integration (if Redis available)
pytest tests/

Integration Testing

Integration tests require:

  • Redis: Running locally (via Docker) or in CI (via service containers)
  • beast-mailbox-core: Installed as dependency

Local Testing:

  • Redis Docker container is automatically managed via conftest.py fixtures
  • Tests gracefully skip if Redis/Docker unavailable
  • Uses separate test database (db=15) to avoid conflicts

CI Testing:

  • Redis service container automatically provided in GitHub Actions
  • Integration tests run against real Redis in CI

🤝 Integration

Required Dependencies

  • beast-mailbox-core >= 0.3.0 - Messaging and discovery

Optional Dependencies

  • beast-observability - Enhanced telemetry
  • Any cloud platform (works with AWS, GCP, Azure, on-prem)

📦 Package Status

Tier: 1 (Foundation)
Phase: Development
Coverage: Target 90%+
Quality: Target zero defects


🔗 Related Packages

  • beast-mailbox-core - Redis-backed mailbox utilities
  • beast-agentic-framework - Multi-agent orchestration
  • beast-observability - Unified telemetry
  • beast-redaction-client - Data classification

📄 License

MIT License - see LICENSE for details.


🙏 Acknowledgments

Part of the Beast Mode multi-agent framework ecosystem.


Built with ❤️ by the Beast Mode team

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

beast_agent-0.1.1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

beast_agent-0.1.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file beast_agent-0.1.1.tar.gz.

File metadata

  • Download URL: beast_agent-0.1.1.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for beast_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 adbba938698df0b4216da4bbe3c4e13bfb60cadaeb289b0837e5be72ed40903c
MD5 3685c9a2d7de9b3bbb7dde8ee6e893e3
BLAKE2b-256 de1af9607ca941c5df39475bd66e5d4f3f4c252fcf81164574480472a450c0ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for beast_agent-0.1.1.tar.gz:

Publisher: publish.yml on nkllon/beast-agent

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

File details

Details for the file beast_agent-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: beast_agent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for beast_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64489a0470bff94cd8cdceb52811d417f6ac8fbaa3f15d99c6fae58b928fd4b9
MD5 12e01a48bd7dbf3f79dad464ac3cc084
BLAKE2b-256 ecd09cd948fb4c465b62b1bfd06fb5da10566a877549fa2f50931ab8d7083a8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for beast_agent-0.1.1-py3-none-any.whl:

Publisher: publish.yml on nkllon/beast-agent

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