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 Maosproject Platform — 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.1.tar.gz (7.8 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.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maos_agent-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 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.1.tar.gz
Algorithm Hash digest
SHA256 6214ce7de3f2ffd7739badcaf75d34ac0b869983c9d4f5f7bbc1abf27542675e
MD5 60fc72a60ea7f737d633b39bea3ceb07
BLAKE2b-256 cbb1e3e157c79380e506b1f5d49d525b111992bb310cd2c2be946cde26f84d17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maos_agent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca3587719f7b6d2383d9ac7efebd48d8ba29fbdcb5753678fdb7991a2ed96f51
MD5 aced664a5a2b5122cb5d46ba9bf3096c
BLAKE2b-256 43889c929fb46883568c1a04694129178bfcaa80d9ee6e4e67b192e5a15bdc55

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 Sentry Error logging StatusPage Status page