Skip to main content

Provider-neutral AI agent runtime and MCP/Skill gateway for Marona Hub connections, managed agents, and bring-your-own-agent integrations.

Project description

Marona Python SDK

Provider-neutral AI agent runtime and MCP/Skill gateway for Marona Hub connections, managed agents, and bring-your-own-agent integrations.

pip install marona

1. Marona Hub

Connect Apps and governed Skills as one neutral MCP tool collection.

from marona import Marona

marona = Marona(api_key="YOUR_MARONA_API_KEY")

# Connect every App and Skill available to this developer key.
connection = marona.hub.connect()

Select a smaller capability set when needed:

connection = marona.hub.connect(
    apps=["group-fund"],
    skills=["create-group-fund"],
)

Use the connection directly:

tools = connection.list_tools()
result = connection.call_tool(
    "skill__create_group_fund",
    {"request": "Create a family savings group fund"},
)

MCPConnection is not tied to OpenAI, LangGraph, CrewAI, or another model vendor. It exposes:

connection.list_tools()
connection.call_tool(name, arguments)
connection.server_url
connection.server_urls
connection.warnings
connection.session

An unresolved App or Skill name does not discard valid tools. Check connection.warnings for its code, selector_type, slug, and corrective message. Authentication, permission, and configured-server failures remain blocking errors.

Marona Hub owns discovery, identity, permissions, App and Skill resolution, approvals, governed execution, and online, offline, or hybrid availability. With no selectors, online and hybrid connections include every capability available to the developer key; offline connections include every capability installed on the device.

Connected Apps execute through Marona governance. When an App such as Google Contacts or Calendar needs sign-in, the tool result includes structuredContent.authorization_url and a link artifact. Pass user_id when calling a tool directly so the resulting service connection belongs to the correct end user:

result = connection.call_tool(
    "contacts__search_contacts",
    {"query": "John"},
    user_id="customer_482",
    conversation_id="chat_91a7",
)

Use the asynchronous methods inside an event loop:

connection = await marona.hub.connect_async(
    apps=["group-fund"],
    skills=["create-group-fund"],
)
tools = await connection.list_tools_async()
result = await connection.call_tool_async(
    "skill__create_group_fund",
    {"request": "Create a family savings group fund"},
)

2. Marona Agent

Use Marona's Agent and Runner when you want one simple managed agent API.

from marona import Agent, Marona, Runner

marona = Marona(api_key="YOUR_MARONA_API_KEY")

tools = marona.hub.connect(
    apps=["sda-books"],
)

agent = Agent(
    name="Customer Assistant",
    model="marona/gpt-5.6",
    instructions="Help the customer.",
    tools=tools,
    tool_choice="auto",
)

result = await Runner.run(
    agent,
    "Download Steps to Christ",
    user_id="customer_482",
    session_id="chat_91a7",
)

print(result.output)

user_id is optional. session_id is also optional and defaults to default. Marona derives the developer scope from the authenticated API key and keeps conversation history isolated by developer, user, and session. In synchronous applications, use Runner.run_sync(...).

tool_choice defaults to "auto". Use "required" when the first model turn must select a connected capability, or "none" to disable tools for the Agent. After discovery Marona requires one exact capability call, then returns to automatic selection so multi-step requests can continue.

Automatic Model And Provider Routing

Use marona/auto for capability-aware model and provider routing. Tools, voice behavior, input restrictions, output restrictions, and routing are all optional:

from marona import Agent, Marona, Runner

marona = Marona(api_key="YOUR_MARONA_API_KEY")
tools = marona.hub.connect()

agent = Agent(
    name="Customer Assistant",
    model="marona/auto",
    instructions=(
        "Help customers clearly and concisely. "
        "Use available tools only when necessary."
    ),
    tools=tools,
    voice={
        "output_voice": "ash",
        "language": "en",
        "turn_detection": "semantic_vad",
        "interruptible": True,
        "input_format": "pcm16",
        "output_format": "pcm16",
    },
    modalities=["text", "image", "audio"],
    output_modalities=["text", "audio"],
    routing={
        "strategy": "balanced",
        "max_cost_usd": 0.02,
        "target_latency_ms": 3000,
        "timeout_ms": 30000,
        "allowed_models": [
            "marona/gpt-5-mini",
            "marona/gemini-2.5-pro",
        ],
        "allowed_providers": [
            "openai",
            "google",
            "openrouter",
        ],
        "fallback": True,
    },
)

result = await Runner.run(
    agent,
    input=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": "Describe the problem shown in this image.",
                },
                {
                    "type": "input_image",
                    "image_url": "https://example.com/damaged-package.jpg",
                },
            ],
        }
    ],
    user_id="customer_482",
    session_id="chat_91a7",
)

print(result.output)

For ordinary conversation, no Hub connection is required:

agent = Agent(name="Customer Assistant")
result = await Runner.run(agent, "Hello")
print(result.output)

Text-only runs return a str. Mixed or media output returns ordered output_text, output_image, output_audio, output_video, and output_file parts. Permission, approval, and service-auth continuations raise MaronaPermissionRequired, MaronaApprovalRequired, or MaronaServiceConnectionRequired.

Streaming

async for event in Runner.stream(
    agent,
    input="Explain this document.",
    user_id="customer_482",
    session_id="chat_91a7",
):
    if event.type == "output_text.delta":
        print(event.delta, end="")

Realtime

from marona import RealtimeRunner

session = await RealtimeRunner.connect(
    agent,
    user_id="customer_482",
    session_id="voice_91a7",
)

async with session:
    await session.send_message("List my notes")
    async for event in session:
        if event.type == "transcript.delta":
            print(event.delta, end="")
        elif event.type == "response.completed":
            print(event.output)
            break

The persistent session also supports send_audio(...) and close(). Provider events, tool discovery, MCP/Skill execution, and function results are handled inside the session; applications receive only normalized Marona events.

Typed Input And Output

Use Pydantic models when an Agent needs a validated contract. Marona validates input before calling a model and returns the validated output model:

from pydantic import BaseModel
from marona import Agent, Runner

class CustomerRequest(BaseModel):
    question: str
    priority: str = "normal"

class CustomerResponse(BaseModel):
    answer: str
    needs_follow_up: bool

agent = Agent(
    name="Customer Assistant",
    model="marona/gpt-5-mini",
    input_type=CustomerRequest,
    output_type=CustomerResponse,
    instructions="Answer the customer's question.",
)

result = await Runner.run(
    agent,
    CustomerRequest(question="When will my order arrive?"),
)

print(result.output.answer)

Multi-Agent

Use Agent.as_tool() for bounded delegation. The parent remains active and combines the specialist result. Use handoff(...) when the destination should take ownership of the conversation:

from marona import Agent, Marona, Runner, ToolContext, function_tool, handoff

marona = Marona(api_key="YOUR_MARONA_API_KEY")
tools = marona.hub.connect()


@function_tool(
    permissions=["billing.refund"],
    timeout_ms=5000,
)
def check_refund(
    amount: float,
    duplicate_charge: bool,
    context: ToolContext,
) -> dict:
    """Check whether a duplicate customer charge qualifies for a refund."""

    return {
        "eligible": duplicate_charge and amount > 0,
        "refund_amount": amount if duplicate_charge else 0,
        "customer_id": context.user_id,
    }

researcher = Agent(
    name="Research Specialist",
    description="Researches bounded customer questions.",
    model="marona/gpt-5-mini",
    tools=tools,
)

billing = Agent(
    name="Billing Specialist",
    description="Owns billing and payment conversations.",
    model="marona/gpt-5-mini",
    instructions="Resolve billing requests using the validated billing function.",
    tools=[check_refund],
    metadata={"permissions": ["billing.refund"]},
)

manager = Agent(
    name="Customer Assistant",
    model="marona/gpt-5.6",
    tools=[
        researcher.as_tool(
            name="research",
            description="Research one bounded question and return the result.",
        ),
    ],
    handoffs=[
        handoff(
            billing,
            name="transfer_to_billing",
            description="Transfer billing and payment requests.",
        ),
    ],
)

result = await Runner.run(
    manager,
    "I was charged twice for USD 24. Check whether I qualify for a refund.",
    user_id="customer_482",
    session_id="support_91a7",
)

print(result.output)
print(result.active_agent.name)
print(result.agent_runs)

The same manager works with Runner.stream(...) and RealtimeRunner.connect(...). Marona validates the complete graph before the first model call, rejects cycles, enforces execution limits, and keeps provider credentials out of agent and model context.

Function Tools

@function_tool and function_tool(existing_function) convert an ordinary Python function into one provider-neutral Marona tool. Marona infers the tool name, description, input schema, and output schema from the function signature, docstring, and type hints. A typed ToolContext parameter is injected by the runtime and never appears in the model schema.

Input, output, permission, approval, and timeout checks run in the SDK that owns the function. The callable and credentials are never sent to Edge or a model. The same tool works unchanged with Runner.run(...), Runner.stream(...), RealtimeRunner.connect(...), and marona.responses.create(...).

Realtime Multi-Agent

Define the complete Agent graph, then pass its manager to RealtimeRunner.connect(...). Delegation tools and handoffs remain available throughout the persistent realtime session:

from marona import Agent, Marona, RealtimeRunner, handoff

marona = Marona(api_key="YOUR_MARONA_API_KEY")
tools = marona.hub.connect()

researcher = Agent(
    name="Research Specialist",
    description="Researches bounded customer questions.",
    model="marona/gpt-5-mini",
    tools=tools,
)

billing = Agent(
    name="Billing Specialist",
    description="Owns billing and payment conversations.",
    model="marona/gpt-5-mini",
    tools=tools,
)

manager = Agent(
    name="Customer Assistant",
    model="marona/gpt-5.6",
    tools=[
        researcher.as_tool(
            name="research",
            description="Research one bounded question and return the result.",
        ),
    ],
    handoffs=[
        handoff(
            billing,
            name="transfer_to_billing",
            description="Transfer billing and payment requests.",
        ),
    ],
)

try:
    session = await RealtimeRunner.connect(
        manager,
        user_id="customer_482",
        session_id="support_voice_91a7",
    )

    async with session:
        await session.send_message("I was charged twice and need help.")

        async for event in session:
            if event.type == "agent.handoff.completed":
                print(event.data["target_agent"])
            elif event.type == "response.completed":
                print(event.output)
                break
finally:
    await marona.aclose()

Marona keeps provider events internal and emits one provider-neutral event stream. After a handoff, the destination Agent owns the following turns.

3. Marona Runtime

Use responses.create(...) when Marona should manage model reasoning, tool selection, permission and approval checks, execution, and the final response.

from marona import Marona

marona = Marona(api_key="YOUR_MARONA_API_KEY")

tools = marona.hub.connect(
    apps=["group-fund"],
    skills=["create-group-fund"],
)

response = marona.responses.create(
    model="marona/gpt-5.6",
    tools=tools,
    input="Create a family savings group fund",
    tool_choice="auto",
)

print(response.output)
model="marona/auto"
model="marona/gpt-5.6"
model="marona/gpt-5-mini"
model="marona/gpt-5-nano"
model="marona/claude-sonnet"
model="marona/gemini-2.5-pro"
model="marona/deepseek-chat"

Use marona/auto when Marona should select both the model and provider. Hard capability requirements are enforced first, a small internal classifier reasons about task type and complexity, and provider health, cost, and latency select where the chosen model runs:

response = marona.responses.create(
    model="marona/auto",
    routing={
        "strategy": "balanced",  # balanced | quality | cost | latency
        "max_cost_usd": 0.02,
        "target_latency_ms": 3000,
        "timeout_ms": 30000,
        "allowed_models": ["marona/gpt-5-mini", "marona/claude-sonnet"],
        "allowed_providers": ["openai", "anthropic", "openrouter"],
        "fallback": True,
    },
    input="Review this distributed system design.",
)

print(response.output)
print(response.model)
print(response.routing)

With a specific marona/... model, Marona keeps that exact model and may only change provider. Direct-provider routes are never rerouted.

The same request also supports direct-provider, private, and local models:

model="openai/gpt-5.6"                       # Marona key + OpenAI key
model="openrouter/anthropic/claude-sonnet"   # OpenRouter
model="anthropic/claude-sonnet"              # Anthropic directly
model="google/gemini"                        # Google directly
model="ollama/qwen3"                         # Ollama
model="litellm/local-qwen"                   # LiteLLM gateway
model="local/qwen"                           # Downloaded/in-process model

Direct provider routes resolve credentials from their standard environment variables. For OpenRouter, set OPENROUTER_API_KEY; Marona automatically uses https://openrouter.ai/api/v1 and preserves the remaining OpenRouter model slug:

response = marona.responses.create(
    model="openrouter/anthropic/claude-sonnet",
    input="Help me with this request",
)

print(response.output)

Register only custom providers or downloaded in-process models:

marona.models.register(
    name="office/company-assistant",
    endpoint="https://models.office.example/v1",
    model="company-assistant-v2",
    api_key="YOUR_PROVIDER_KEY",
)

marona.models.register(
    name="local/qwen",
    executor=qwen_executor,
    context_window=8192,
    max_output_tokens=512,
)

For asynchronous applications, call await marona.responses.create_async(...).

Images

from marona import Marona

marona = Marona(api_key="YOUR_MARONA_API_KEY")

response = marona.responses.create(
    model="openai/gpt-5.6",
    input=[
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "Summarize this image."},
                {"type": "input_image", "image_url": "https://example.com/image.jpg"},
            ],
        }
    ],
)

print(response.output)

Files

from marona import Marona

marona = Marona(api_key="YOUR_MARONA_API_KEY")

response = marona.responses.create(
    model="openai/gpt-5.6",
    input=[
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "Summarize this file."},
                {
                    "type": "input_file",
                    "filename": "report.pdf",
                    "file_data": "data:application/pdf;base64,...",
                    "detail": "high",
                },
            ],
        }
    ],
)

print(response.output)

4. Bring Your Own Agent

The external framework owns its Agent, reasoning, and orchestration. Marona supplies neutral MCP tools and retains authorization, approvals, and execution.

OpenAI Agents SDK Example

from marona import Marona
from agents import Agent, Runner

marona = Marona(api_key="YOUR_MARONA_API_KEY")
connection = marona.hub.connect(
    apps=["group-fund"],
    skills=["create-group-fund"],
)

# Adapt only at the framework boundary. Marona itself remains vendor-neutral.
framework_tools = your_openai_agents_mcp_adapter(connection)

agent = Agent(
    name="Group Fund Assistant",
    model="marona/gpt-5.6",
    instructions="Help users create and manage group funds.",
    tools=framework_tools,
)

result = Runner.run_sync(agent, "Create a family savings group fund")
print(result.final_output)

your_openai_agents_mcp_adapter(...) represents the OpenAI-specific adapter at the framework boundary; it is not part of Marona's vendor-neutral core API.

An MCP-compatible framework can map its standard tool-list and tool-call hooks directly to connection.list_tools() and connection.call_tool(...). Marona does not claim that one Python tool object automatically satisfies every agent framework's proprietary interface.

8. Agent-to-Agent (A2A)

Use peers for independently deployed agents that implement the open A2A protocol. Marona discovers each Agent Card, lets the model select the relevant peer, keeps peer credentials in the SDK process, and returns normalized tasks and artifacts.

import os

from marona import Agent, Runner
from marona.a2a import A2APeer, A2APolicy

flight_agent = A2APeer(
    name="flight_agent",
    url="https://flight-agent.example.com",
    authentication={
        "type": "bearer",
        "token": os.environ["FLIGHT_AGENT_TOKEN"],
    },
    permissions=["travel.route.read", "travel.dates.read"],
    data_policy={
        "deny": ["payment_credentials", "identity_document"],
    },
)

travel_agent = Agent(
    name="Travel Manager",
    model="marona/auto",
    instructions="Coordinate complete travel plans.",
    peers=[flight_agent],
    metadata={
        "permissions": ["travel.route.read", "travel.dates.read"],
    },
)

result = await Runner.run(
    travel_agent,
    "Find a flight from Harare to Cape Town.",
    user_id="customer_482",
    session_id="travel_91a7",
)

print(result.output)
print(result.a2a_events)

Use the same peer in a persistent, provider-neutral realtime session:

from marona import RealtimeRunner

session = await RealtimeRunner.connect(
    travel_agent,
    user_id="customer_482",
    session_id="travel_voice_91a7",
)

async with session:
    await session.send_message("Find a direct flight to Cape Town.")

    async for event in session:
        if event.type.startswith("a2a."):
            print(event.type, event.data)
        if event.type == "response.completed":
            print(event.output)
            break

Expose a Marona Agent to other A2A clients:

from marona.a2a import A2AServer

server = A2AServer(
    agent=travel_agent,
    url="https://travel-agent.example.com",
    skills=[
        {
            "id": "coordinate-trip",
            "name": "Coordinate trip",
            "description": "Coordinate flights, hotels, and budget.",
        }
    ],
)

server.run(host="0.0.0.0", port=8100)

The same peers work with Runner.stream(...) and RealtimeRunner.connect(...). tools remain functions, Apps, Skills, MCP, and internal bounded delegation; handoffs remain internal ownership transfers; peers are independent A2A collaborators. Peer permission declarations are enforced locally before execution, credentials remain outside model context, and denied fields are removed before the request leaves the process.

9. Publish A Skill

Every workflow entry uses step(); type selects reasoning, approval, or App execution. Set visibility="public" for Hub discovery or "private" for only the owning developer workspace. New Skills default to private.

from marona import Marona
from marona.skills import skill, step


@skill(
    name="create-group-fund",
    description="Create a group fund after explicit user approval.",
    visibility="public",
    governs=["group-fund.create_group"],
)
def create_group_fund():
    request = step(
        id="understand-request",
        type="reasoning",
        instruction="Extract the group name and currency.",
        inputs={"message": "{{ context.user_message }}"},
        outputs={"name": "string", "currency": "string"},
    )
    permission = step(
        id="confirm-create",
        type="approval",
        message=f"Create '{request.name}' in {request.currency}?",
        outputs={"approved": "boolean"},
    )
    return step(
        id="create-group",
        type="app",
        app="group-fund",
        capability="group-fund.create_group",
        instruction="Create the approved group.",
        condition=permission.approved,
        inputs={"name": request.name, "currency": request.currency},
        outputs={"group_id": "string", "name": "string"},
    )


marona = Marona(api_key="YOUR_MARONA_API_KEY")
marona.skills.publish(create_group_fund, version="1.0.0")

Execution Modes

Set mode when creating Marona:

marona = Marona(
    api_key="YOUR_MARONA_API_KEY",
    mode="hybrid",
)
  • online: network models and online MCP targets are allowed.
  • hybrid: local/private execution may fall back to online execution.
  • offline: only installed local Apps, Skills, data, and local models run.

Changing model never changes App, Skill, permission, approval, or MCP rules.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

marona-0.12.0.tar.gz (99.3 kB view details)

Uploaded Source

Built Distribution

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

marona-0.12.0-py3-none-any.whl (88.1 kB view details)

Uploaded Python 3

File details

Details for the file marona-0.12.0.tar.gz.

File metadata

  • Download URL: marona-0.12.0.tar.gz
  • Upload date:
  • Size: 99.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for marona-0.12.0.tar.gz
Algorithm Hash digest
SHA256 052f5568f2bcb02b083e98a37e1b49c2f889f26a0f1fecf438649d9ee6785d96
MD5 49887f578980792d7a80aec0b9ab661d
BLAKE2b-256 2648ae0061fce8301b36a1e00dacc72bc80ee1baa09a9df259773ff83d96007b

See more details on using hashes here.

File details

Details for the file marona-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: marona-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 88.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for marona-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46bc5b2e173c625c5297ff4c87d4b10261d8b819fc320cbdbe619ca6ff1de651
MD5 c27024b769fada51674e8096dd3c2619
BLAKE2b-256 9c08a12fdf83e77f9d70500efd54c510b8ad93d3bfa2ad6dd210e05a7af57a60

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