Skip to main content

lp-agent-runtime-sdk

Python SDK for running agent-runtime workflows. Wraps the agent-runtime binary to execute declarative .agent bundles from Python, with support for registering Python functions as callable tools.

Installation

pip install lp-agent-runtime-sdk
# or
uv add lp-agent-runtime-sdk

The package ships pre-built binaries for macOS (arm64, amd64), Linux (amd64, arm64), and Windows (amd64) — no separate install required.

Quick Start

from agent_runtime import Runtime, RunError

rt = Runtime()

@rt.tool("pricing.get_quote", version="v1")
def get_quote(sku: str, quantity: int) -> dict:
    return {"unit_price": 9.99, "currency": "USD"}

try:
    output = rt.run("./my_bundle.agent", inputs={"sku": "ABC-1", "quantity": 10})
    print(output)
except RunError as e:
    print(f"Flow failed: {e} (run_id={e.run_id})")

Authoring Bundles

Bundles are directories with a .agent extension containing a declarative flow definition. See FLOWS.md in the main repo for the full authoring guide.

API Reference

Runtime(binary=None, env=None)

Creates a runtime instance.

  • binary — explicit path to the agent-runtime binary (optional)
  • env — extra environment variables merged into the subprocess environment

@rt.tool(name, version="v1")

Decorator that registers a Python function as a tool callable by the workflow. The tool reference inside the bundle must match name@version.

@rt.tool("supplier_api.get_price", version="v1")
def get_price(item_code: str) -> dict:
    return {"price": 42.0}

# Async tools are also supported
@rt.tool("data.fetch_record", version="v1")
async def fetch_record(record_id: str) -> dict:
    ...

rt.run(bundle, inputs=None, on_event=None) -> dict

Executes a bundle synchronously and returns the flow output as a dict.

rt.arun(bundle, inputs=None, on_event=None) -> dict

Async version of run. Use with await inside an async context.

result = await rt.arun("./bundle.agent", inputs={"query": "hello"})

rt.validate(bundle)

Validates a bundle directory. Raises RuntimeError if the bundle is invalid.

File Inputs

Use FileInput to pass a local file as a flow input. The path is resolved to an absolute path automatically.

from agent_runtime import Runtime, FileInput

rt = Runtime()
output = rt.run("./ocr_bundle.agent", inputs={"document": FileInput("./invoice.pdf")})

Streaming Events

Pass an on_event callback to receive TraceEvent objects as the workflow executes.

def on_event(event: TraceEvent) -> None:
    print(f"[{event.event}] node={event.node} duration={event.duration_ms}ms")

rt.run("./bundle.agent", inputs={...}, on_event=on_event)

Key TraceEvent fields:

Field Type Description
event str Event type (e.g. node.start, node.done, tool.call)
node str Node name in the flow
node_type str Node type (e.g. llm, tool, router)
tool str Tool reference if a tool was called
model str Model name for LLM nodes
input_tokens int Tokens consumed
output_tokens int Tokens produced
duration_ms int Node execution time
error str Error message if the node failed
output dict Node output

Traces & Debugging

Where traces go

Trace events are emitted by the runtime binary to stdout as newline-delimited JSON and streamed to you in real time via the on_event callback. There is no separate log file — if you don't attach a callback, events are silently consumed and discarded.

To capture a full trace for debugging, collect all events into a list:

from agent_runtime import Runtime, TraceEvent, RunError

rt = Runtime()
trace: list[TraceEvent] = []

try:
    output = rt.run("./bundle.agent", inputs={...}, on_event=trace.append)
except RunError as e:
    # Flow-level failure — the error message and run_id are on the exception.
    # Check the trace for the node that produced the error.
    failed = [ev for ev in trace if ev.error]
    for ev in failed:
        print(f"node={ev.node} error={ev.error}")
    raise

Event types

Event When it fires
flow_start Flow begins executing
flow_done Flow completed successfully
node_start A node begins executing
node_done A node finished (check ev.error for failure)
tool_call The runtime is calling a registered tool
tool_done Tool call returned

Error channels

There are two ways a run can surface an error:

Node-level — a node fails but the flow may continue (e.g. a retry). Delivered as a TraceEvent with event="node_done" and a non-empty error field. The attempt and max_retries fields indicate retry state.

Flow-level — the flow terminates in an error state. The SDK raises RunError with the message and run_id. Check the collected trace to find which node caused it.

Binary crash — the agent-runtime process exits with a non-zero code (misconfigured bundle, missing env var, etc.). The SDK raises RuntimeError with the stderr output as the message. This is distinct from a flow error and does not produce a RunError.

Typical debug loop

  1. Collect the full trace with on_event=trace.append
  2. On RunError, filter [ev for ev in trace if ev.error] to find the failing node
  3. Inspect ev.inputs, ev.args, and ev.output on surrounding events to understand the data at that point
  4. Fix the bundle or tool, then re-run

Binary Resolution

The SDK locates the agent-runtime binary in this order:

  1. binary argument passed to Runtime()
  2. AGENT_RUNTIME_BIN environment variable
  3. Bundled platform binary (included in the package)
  4. agent-runtime on PATH

Development

uv run pytest          # run tests
uv run ruff check .    # lint

Metadata

Release files for lp-agent-runtime-sdk 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lp-agent-runtime-sdk 0.1.12
File
lp_agent_runtime_sdk-0.1.12-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
lp_agent_runtime_sdk-0.1.12-py3-none-manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
lp_agent_runtime_sdk-0.1.12-py3-none-manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
lp_agent_runtime_sdk-0.1.12-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
lp_agent_runtime_sdk-0.1.12-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 129.0 MB

Release files / lp_agent_runtime_sdk-0.1.12-py3-none-win_amd64.whl

Download URL lp_agent_runtime_sdk-0.1.12-py3-none-win_amd64.whl
Size 43.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
fbedfc8e33a94648af1714fc5107113c1161734d815305876cc12ed3d6b0bf0e
BLAKE2b-256 checksum
How to use checksums
0107b0e1d56b93f3399bdbfc5a7a0d09b5c6cafd36945bb876e1cf1a1b20c564
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Release files / lp_agent_runtime_sdk-0.1.12-py3-none-manylinux2014_x86_64.whl

Download URL lp_agent_runtime_sdk-0.1.12-py3-none-manylinux2014_x86_64.whl
Size 26.1 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0cb0c40d60e3e262822d13769a992b0e44d4dfb9bcbd4088c025a0f046e1b6cb
BLAKE2b-256 checksum
How to use checksums
daa2b2712b115b9d31e1e0d0ecfbfdf710bd545e2b9b141338fa60dd49774c64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Release files / lp_agent_runtime_sdk-0.1.12-py3-none-manylinux2014_aarch64.whl

Download URL lp_agent_runtime_sdk-0.1.12-py3-none-manylinux2014_aarch64.whl
Size 34.1 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
095456a2d71b47bdcd43ada5fc797fe50a7d94dad8571c2e9f302a0513cd0305
BLAKE2b-256 checksum
How to use checksums
7827abdf688cba7487cbab53826d5a8611e144cdd14ab107e449287f2fd52b05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Release files / lp_agent_runtime_sdk-0.1.12-py3-none-macosx_11_0_arm64.whl

Download URL lp_agent_runtime_sdk-0.1.12-py3-none-macosx_11_0_arm64.whl
Size 8.4 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9f5f86bcb7b380ca2e90d89d8a2435af3b801953934c00a0e42677bbea3b1726
BLAKE2b-256 checksum
How to use checksums
b745c85c4af081160bd666edd5203f1193e4badc6b320e83c5d12bbbf7455be7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Release files / lp_agent_runtime_sdk-0.1.12-py3-none-macosx_10_12_x86_64.whl

Download URL lp_agent_runtime_sdk-0.1.12-py3-none-macosx_10_12_x86_64.whl
Size 17.4 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2d4b57d1055a4cc25ac15322dbe23cb918f95a464e532252472ea1d64ca81271
BLAKE2b-256 checksum
How to use checksums
946bd958a01b3f687e2e571b225cb2fe4e36ea70d1455302049ecd27048de10d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Security for lp-agent-runtime-sdk 0.1.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for lp_agent_runtime_sdk-0.1.12-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page