Skip to main content

Portia Labs Eval framework for evaluating agentic workflows.

Project description

🧵 SteelThread: Agent Evaluation Framework

SteelThread is a flexible evaluation framework built around Portia, designed to support robust evals and stream based testing of agentic workflows. It enables configurable datasets, custom metric definitions, LLM-based judging, and stubbed tool behaviors for reproducible and interpretable scoring.


🚀 Getting Started

1. Install using your framework of choice

pip

pip install steel-thread

poetry

poetry add steel-thread

uv

uv add steel-thread

2. Create your datasets

SteelThread is designed around deep integration with Portia. It uses data from Portia Cloud to generate test cases and evals.

When running monitoring through SteelThread we offer two distinct types:

  • Evals are static datasets designed to be run multiple times to allow you to analyze how changes to your agents affect performance.
  • Streams are dynamic streams that automatically include your latest plans and plan runs, allowing you to measure performance in production.

Both types of monitoring can be configured via the cloud dashboard.. Once you've created a dataset record the name of it.


3. Basic Usage

Run a full suite of evals and streams using the name of the dataset from step 2. This will use the built in set of evaluators to give you data out of the box.

from portia import Config, LogLevel, Portia
from steelthread.steelthread import SteelThread, StreamConfig, EvalConfig

# Setup
config = Config.from_default(default_log_level=LogLevel.CRITICAL)
st = SteelThread()

# Process stream
st.process_stream(
    StreamConfig(stream_name="stream_v1", config=config, additional_tags={"feeling": "neutral"})
)

# Run evals
portia = Portia(config)
st.run_evals(
    portia,
    EvalConfig(
        eval_dataset_name="evals_v1",
        config=config,
        iterations=4,
    ),
)

🛠️ Features

🧪 Custom Metrics

Define your own evaluators by subclassing Evaluator:

from steelthread.evals.evaluator import Evaluator
from steelthread.metrics.metric import Metric

class EmojiEvaluator(Evaluator):
    def eval_test_case(
        self,  
        test_case: EvalTestCase,
        final_plan: Plan,
        final_plan_run: PlanRun,
        additional_data: PlanRunMetadata, 
    ):
        output = final_plan_run.outputs.final_output.get_value() or ""
        count = output.count("😊")
        score = min(count / 2, 1.0)
        return Metric(score=score, name="emoji_score", description="Checks for emoji use")

🧩 Tool Stubbing

Stub tool responses deterministically for fast and reproducible testing:

from steelthread.portia.tools import ToolStubRegistry, ToolStubContext

def weather_stub_response(
    ctx: ToolStubContext,
) -> str:
    """Stub for weather tool to return deterministic weather."""
    city = ctx.kwargs.get("city", "").lower()
    if city == "sydney":
        return "33.28"
    if city == "london":
        return "2.00"

    return f"Unknown city: {city}"


# Run evals with stubs + custom evaluators.
portia = Portia(
    config,
    tools=ToolStubRegistry(
        DefaultToolRegistry(config),
        stubs={
            "weather_tool": weather_stub_response,
        },
    ),
)

📊 Metric Reporting

SteelThread is designed around plugable metrics backends. By default metrics are logged and sent to Portia Cloud for visualization but you can add additional backends via the config options.


🧪 Example: End-to-End Test Script

See how everything fits together:

from steelthread.steelthread import SteelThread, EvalConfig
from steelthread.portia.tools import ToolStubRegistry
from steelthread.metrics.metric import Metric
from steelthread.evals.evaluator import Evaluator
from portia import Config, Portia, DefaultToolRegistry, ToolRunContext

# Custom tool stub
def weather_stub_response(
    ctx: ToolStubContext,
) -> str:
    """Stub for weather tool to return deterministic weather."""
    city = ctx.kwargs.get("city", "").lower()
    if city == "sydney":
        return "33.28"
    if city == "london":
        return "2.00"

    return f"Unknown city: {city}"


# Custom evaluator
class EmojiEvaluator(Evaluator):
    def eval_test_case(self, test_case,plan, plan_run, metadata):
        out = plan_run.outputs.final_output.get_value() or ""
        count = out.count("🌞")
        return Metric(score=min(count / 2, 1.0), name="emoji_score", description="Emoji usage")

# Setup
config = Config.from_default()
st = SteelThread()
portia = Portia(
    config,
    tools=ToolStubRegistry(DefaultToolRegistry(config), {"weather_tool": weather_stub_response})
)

st.run_evals(
    portia,
    EvalConfig(
        eval_dataset_name="evals_v1",
        config=config,
        iterations=4,
    ),
)

🧪 Testing

Write tests for your metrics, plans, or evaluator logic using pytest:

uv run pytest tests/

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

steel_thread-0.1.13.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

steel_thread-0.1.13-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file steel_thread-0.1.13.tar.gz.

File metadata

  • Download URL: steel_thread-0.1.13.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.9

File hashes

Hashes for steel_thread-0.1.13.tar.gz
Algorithm Hash digest
SHA256 9abc60d98daa2ec29a1e5dfc4c6bba049abea5ad22e64bbf63c80b02a069ebcd
MD5 4e442add17fc589219e20c2601e291aa
BLAKE2b-256 120c66c546a97071d2ff7f86d8bc932602a53cfe6ee5d9fc3d5e1f048c00b6ff

See more details on using hashes here.

File details

Details for the file steel_thread-0.1.13-py3-none-any.whl.

File metadata

File hashes

Hashes for steel_thread-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 35d35a29df74dde76feccc19214f7c39efd1815187b4d58e1776c3d90132d23b
MD5 8e27b4be1b9805426c4adcb6ceaf5f63
BLAKE2b-256 890682bc36c449049e604bffc2a5f80bc858b45d2ede33e6b51d3e87e313e696

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