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.3.tar.gz (136.8 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.3-py3-none-any.whl (175.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marlo_sdk-0.0.3.tar.gz
  • Upload date:
  • Size: 136.8 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.3.tar.gz
Algorithm Hash digest
SHA256 ae02b91bedc1424f2df309fc23a47d562128bc707249adc54f34486ae2e02e34
MD5 220bdbcc4b6ca381c84c774942fa4a5c
BLAKE2b-256 c0c3007f1afb95367b51a7f3f2763b163978d83d5d5b9e2e521c68d60ef64d65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: marlo_sdk-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 175.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d83a4b240a88dc6b00b31b5994b3d9012825cf2ad444c5b4ff9d6f01fc2dd7fa
MD5 5ff64bb77521262826a8b3a85c3f6c6f
BLAKE2b-256 943f00d6ff802740e9fc4d7cd437bdc8640ba1cf32cb4278b0436070bd395098

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