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 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.2.tar.gz (136.6 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.2-py3-none-any.whl (175.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marlo_sdk-0.0.2.tar.gz
  • Upload date:
  • Size: 136.6 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.2.tar.gz
Algorithm Hash digest
SHA256 3dee00dcfcd2af8ba8ba7d64c30a4d812532b885c705e7965698b04bfd84af86
MD5 c94995b1a9fa15a76ac65e69c584137f
BLAKE2b-256 beacb7defca55e0d340ad5cdd0b5533b8045334d9afc8cba8c27bcd49b70280e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: marlo_sdk-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 175.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0bcf8b02679afbffdbe06ae5873a5060ccf295c7e5d5721e85b1c87255184f80
MD5 201866957057a1ccc726e60552b524d8
BLAKE2b-256 3e19688069a2e1651f989a5dd5c8796974fc3f6d251dc9c974ac03907017181a

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