Skip to main content

CTO here.

Here is the README.md.

It is written to be "Marketing-Engineering" aligned. It doesn't just say how to use it; it explains why a developer needs it (to stop their agents from dying silently on Spot instances).

I’ve added badges, a clear "Quick Start," and a section linking the metrics directly to the Grafana dashboard we just built.


Maos Agent SDK

The official Python SDK for building resilient, observable AI Agents on the Maos Platform.

maos-agent provides the "Day 2" primitives required to run autonomous agents in production:

  1. Zero-Config Telemetry: Automatically emits Prometheus metrics for every tool call, token used, and cognitive step.
  2. Spot Instance Resilience: Handles SIGTERM signals from Kubernetes to allow graceful state checkpointing before node termination.

Installation

pip install maos-agent

Quick Start

Wrap your existing agent code with the Maos decorators to instantly get Grafana dashboards and Spot interruption protection.

import time
import random
from maos_agent import MaosAgent, SpotInterruptionError

# 1. Initialize (Starts Prometheus server on port 8000)
agent = MaosAgent(service_name="financial-analyst", version="v1.2")

# 2. Define Tools (Auto-tracked for success/failure rates)
@agent.tool(name="stock_lookup")
def get_stock_price(ticker: str):
    # Simulate work
    if random.random() < 0.05:
        raise ConnectionError("API Timeout") # Recorded as 'error' in Grafana
    return 150.00

# 3. The Agent Loop
def run_job():
    # Track duration, steps, and success automatically
    with agent.task("analyze_portfolio") as task:
        print("Starting analysis...")
        
        for i in range(5):
            # --- THE MAOS GUARANTEE ---
            # Checks if K8s sent a termination signal (Spot reclaim).
            # Raises SpotInterruptionError if node is draining.
            agent.check_health() 
            
            # Record a "cognitive step" (thinking loop)
            task.step() 
            
            price = get_stock_price("AAPL")
            time.sleep(1)

if __name__ == "__main__":
    try:
        run_job()
    except SpotInterruptionError:
        print("🚨 SPOT RECLAIM DETECTED! SAVING STATE TO REDIS...")
        # Checkpoint your agent's memory here so it can resume on a new node
        exit(0)

Key Features

1. Automatic Telemetry (The "Brain Scan")

Stop guessing if your agent is working. The SDK automatically exposes a /metrics endpoint on port 8000 (configurable) with standard Prometheus metrics:

Metric Name Type Description
maos_agent_tool_calls_total Counter Tracks tool usage + Success/Error rates.
maos_agent_steps_per_goal Histogram Detects "Loops of Death" (agents spinning in circles).
maos_agent_token_usage_total Counter Tracks cost (Input vs Output tokens).
maos_agent_task_duration_seconds Histogram End-to-end latency of jobs.

Compatible with the Maos Agent Quality Dashboard.

2. Graceful Shutdown (The "Money Saver")

Maos runs agents on Spot Instances to save you 90% on compute. However, Spot nodes can disappear with a 2-minute warning.

The agent.check_health() method abstracts the complexity of Kubernetes signal handling.

  • Normal operation: Returns immediately.
  • During Drain: Raises SpotInterruptionError.

Best Practice: Call check_health() inside your main while loop or before every LLM call.


Configuration

You can configure the agent via environment variables or constructor arguments.

Environment Variable Default Description
MAOS_SERVICE_NAME unknown-agent The name of your agent (for filtering in Grafana).
MAOS_METRICS_PORT 8000 Port to expose Prometheus metrics.
MAOS_LOG_LEVEL INFO Logging verbosity.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

  1. Fork the repo.
  2. Create a feature branch (git checkout -b feature/langchain-integration).
  3. Commit your changes.
  4. Open a Pull Request.

Built by Maos AI — The Control Plane for Autonomous Compute.

Download files

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

Source Distribution

maos_agent-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

maos_agent-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file maos_agent-0.1.0.tar.gz.

File metadata

  • Download URL: maos_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for maos_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd3152dbb1f559a8e4db932254fa0d45deac7a25748eaa42243772dbe69acdbc
MD5 87b67385dd7a8f712e3db2b8169982ca
BLAKE2b-256 3c7db376ce3c5f05d543fdf54fa8fc3e4e836cfab1d828ab3fecfb5842cac4fa

See more details on using hashes here.

File details

Details for the file maos_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: maos_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for maos_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b117887493d18d863fee82f31355e13f2df7b4b065b85bb3adc442f1fe3df8
MD5 a3b95f6d7974b55ad3dc30df1d25b8da
BLAKE2b-256 96d2503c72074f4b77d369e839f48a4cc790fc2197303b87039214127287e6f2

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