Skip to content

Agent integration

This guide shows how to connect your agent to MorganaBench using our CLI and SDK. The division of labor: you know how to drive your agent; the CLI and SDK handle the MorganaBench side. Examples use Python, but the TypeScript SDK mirrors them.

Before you start

Install the mb CLI and log in by following the CLI Guide, then install the Python SDK:

pip install "morgana-bench-sdk>=0.5"

Evaluating your agent on a benchmark

At its simplest, an evaluation is a single shell pipeline — download a benchmark, run your agent over it, and create the evaluation from the results:

mb benchmark download <benchmark-id> \
  | python run_your_agent.py \
  | mb eval create "<name>" --benchmark <benchmark-id> --metrics <your-metrics>

Each stage streams JSONL: benchmark download emits one example per line, your script rewrites each line with your agent's output, and eval create reads the result from stdin (since --file is omitted).

The middle stage, run_your_agent.py, is the only part you write. It uses the SDK's Pydantic models to parse and re-serialize MorganaBench's data formats, leaving you free to focus on your agent:

# run_your_agent.py
import sys
import mb.entities as mbe  # MorganaBench SDK


def invoke_agent(inputs: mbe.Inputs) -> mbe.Outputs:
    # 1. convert `inputs` into your agent's native format
    # 2. invoke your agent
    # 3. convert its response back into `mbe.Outputs`
    ...


for line in sys.stdin:
    example = mbe.Example.model_validate_json(line)
    example.outputs = invoke_agent(example.inputs)
    print(example.model_dump_json(), file=sys.stdout)

invoke_agent is where all your agent-specific logic lives: building its native input, authenticating, calling the agent, and mapping its response back to mbe.Outputs. Everything else is boilerplate the SDK handles for you.

This is the minimal pattern. Real integrations usually process examples concurrently — with asyncio, a thread pool, or batched requests — so a full benchmark runs in a fraction of the time.