Skip to main content

The official Python SDK for Marlo - the agent learning platform

Project description

marlo-sdk

The official Python SDK for Marlo - the agent learning platform.

Marlo enables AI agents to learn and improve autonomously in production. It captures agent behavior, evaluates outcomes, and turns failures into actionable learnings.

PyPI version Downloads Downloads/month License: MIT

Installation

pip install marlo-sdk

Quick Start

import marlo

# Initialize
marlo.init(api_key="your-api-key")

# Register your agent
marlo.agent(
    name="support-bot",
    system_prompt="You are a customer support agent.",
    tools=[{"name": "lookup_order", "description": "Find order by ID"}]
)

# Track a task
with marlo.task(thread_id="thread-123", agent="support-bot") as task:
    task.input("Where is my order?")

    # Your agent logic here...

    task.output("Your order ships tomorrow.")

# Shutdown before exit
marlo.shutdown()

Why Marlo?

Agents fail silently in production. The same mistakes repeat because failures aren't captured in a reusable form. Marlo solves this with a learning loop:

  1. Capture - Record LLM calls, tool calls, and outcomes
  2. Evaluate - Score task outcomes automatically
  3. Learn - Generate guidance from failures
  4. Apply - Inject learnings into future tasks

API

Initialize

marlo.init(api_key)

Register Agent

marlo.agent(name, system_prompt, tools, mcp=None, model_config=None)
Parameter Type Description
name str Unique agent identifier
system_prompt str Agent's system prompt
tools list[dict] Available tools
mcp list[dict] MCP servers (optional)
model_config dict Model settings (optional)

Track Tasks

with marlo.task(thread_id, agent, thread_name=None) as task:
    task.input(text)           # User input
    task.output(text)          # Agent response
    task.llm(model=..., usage=..., messages=..., response=...)
    task.tool(name, input, output, error=None)
    task.reasoning(text)       # Chain-of-thought
    task.error(message)        # Mark as failed

Fetch Learnings

with marlo.task(thread_id="user-123", agent="support-bot") as task:
    task.input(user_message)

    learnings = task.get_learnings()

    if learnings:
        learnings_text = learnings.get("learnings_text", "")
        if learnings_text:
            system_prompt += f"\n\nLearnings:\n{learnings_text}"

Multi-Agent

with marlo.task(thread_id="thread-1", agent="orchestrator") as parent:
    parent.input("Research AI trends")

    with parent.child(agent="researcher") as child:
        child.input("Search for AI trends")
        child.output("Found 3 sources...")

    parent.output("Report complete")

Shutdown

marlo.shutdown()

Full Example

import marlo

marlo.init(api_key="your-api-key")

marlo.agent(
    name="support-bot",
    system_prompt="You are a customer support agent.",
    tools=[{"name": "lookup_order", "description": "Find order by ID"}]
)

def handle_message(user_input: str, thread_id: str) -> str:
    with marlo.task(thread_id=thread_id, agent="support-bot") as task:
        task.input(user_input)

        # Apply learnings from past interactions
        learnings = task.get_learnings()
        system_prompt = "You are a customer support agent."
        if learnings:
            learnings_text = learnings.get("learnings_text", "")
            if learnings_text:
                system_prompt += f"\n\nLearnings:\n{learnings_text}"

        # Track tool call
        task.tool("lookup_order", {"id": "123"}, {"status": "shipped"})

        # Track LLM call
        response = "Your order ships tomorrow."
        task.llm(
            model="gpt-4",
            usage={"input_tokens": 100, "output_tokens": 25},
            messages=[{"role": "user", "content": user_input}],
            response=response
        )

        task.output(response)
        return response

marlo.shutdown()

Requirements

  • Python 3.11+

Links

License

MIT

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

marlo_sdk-0.0.5.tar.gz (146.7 kB view details)

Uploaded Source

Built Distribution

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

marlo_sdk-0.0.5-py3-none-any.whl (187.8 kB view details)

Uploaded Python 3

File details

Details for the file marlo_sdk-0.0.5.tar.gz.

File metadata

  • Download URL: marlo_sdk-0.0.5.tar.gz
  • Upload date:
  • Size: 146.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for marlo_sdk-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3062ae820130b45f723c580d41a290e8e60fdf668bdb1c2c5d4e31c52a1ce403
MD5 fd06a7ffec70d62e54853ad93519ba6c
BLAKE2b-256 fa5c6aa6661ccd8d6ab8cc5a77b9ae2279c0f34f7a240073f2a75f36b3e5dddf

See more details on using hashes here.

File details

Details for the file marlo_sdk-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: marlo_sdk-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 187.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for marlo_sdk-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 96991bc402ce9215a5cac84960787d9d8b57e442a685afd3c05f21123f862f99
MD5 5f19b6c822764602d7674f88466ace74
BLAKE2b-256 4ef33393d634dbbcc7e865728d507a33c00205a7305e962d0d4b0a2d378cb67f

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