agentrunner
Host-agnostic LLM agent execution on top of the OpenAI Agents SDK.
AgentRunner wraps the Agents SDK Runner with the production concerns you'd
otherwise rewrite per project:
- Model fallback on rate-limit / provider errors (policy supplied by you)
- Streaming with automatic
<think>…</think>chain-of-thought filtering - Structured-output extraction from varied SDK result shapes, with tolerant JSON sanitization/repair
- Self-correction: validate output, re-prompt on violations, then a
deterministic
normalize()fallback - Tracing hooks (e.g. Langfuse) and per-request context — all injected, no hard dependency
- Token clamping, timeouts, and structured error enrichment
The package depends only on openai-agents, openai, and pydantic. It has
no knowledge of any host application — you inject the model layer and
optional hooks via a small protocol.
Install
pip install boundless-agentrunner
The distribution is published as boundless-agentrunner (the agentrunner name
on PyPI was taken); the import name is still agentrunner:
import agentrunner
Quick start
AgentRunner resolves its model layer from an injected
ModelClientProvider. Configure it once at startup:
from agentrunner import AgentRunner, configure_agentrunner, ModelClientProvider
class MyProvider: # implements ModelClientProvider (a typing.Protocol)
default_rate_limit_delay_seconds = 1.0
max_rate_limit_delay_seconds = 8.0
def create_model_provider_for_model(self, model_key, provider_override=None):
# return (agents-SDK ModelProvider, resolved_model_id)
...
async def retry_with_fallback(self, model_key, run_with_model, **kw):
# run `run_with_model(resolved_model, provider)` with your fallback policy;
# return (result, successful_model)
...
def get_fallback_models(self, model): return []
def get_provider_for_model(self, model): return "myprovider"
def get_model_setting_aliases(self, resolved_model): return []
def clamp_max_tokens(self, model, max_tokens): return max_tokens
def is_rate_limit_error(self, exc): ...
def is_provider_error(self, exc): ...
configure_agentrunner(model_provider=MyProvider())
# then anywhere:
from agents import Agent
result = await AgentRunner.run(Agent(name="demo", model="...", instructions="..."), "hello")
Batteries-included: OpenRouter
Don't want to write a provider? Use the bundled OpenRouter one — a single
OPENROUTER_API_KEY reaches every model family (Claude, GPT, Llama, Qwen,
DeepSeek, Gemini, …) through OpenRouter's OpenAI-compatible endpoint, with model
fallback built in:
import os
from agentrunner import configure_agentrunner
from agentrunner.providers import OpenRouterModelClientProvider
configure_agentrunner(
model_provider=OpenRouterModelClientProvider(
# api_key defaults to $OPENROUTER_API_KEY
fallback_models=["anthropic/claude-sonnet-4.5", "openai/gpt-4o-mini"],
)
)
from agents import Agent
result = await AgentRunner.run(
Agent(name="demo", model="anthropic/claude-sonnet-4.5", instructions="..."),
"hello",
)
Models are addressed by their OpenRouter slug (vendor/model). The provider
forces Chat Completions (OpenRouter doesn't fully implement the Responses API),
honors the validation-retry budget, and classifies rate-limit/provider errors
for fallback.
Lazy configuration
If you can't configure at startup, register a bootstrap that runs on first use:
from agentrunner.runtime import register_bootstrap
register_bootstrap(lambda: configure_agentrunner(model_provider=MyProvider()))
Optional hooks
configure_agentrunner also accepts:
trace_processor_factory— returns an Agents-SDK trace processor (e.g. Langfuse)prompt_correction_emitter— async callback to record self-correction eventslangfuse_prompt_resolver— returns(prompt_name, prompt_version)for events
Output validation / self-correction
from agentrunner.output_validation import BoundedTextValidator
result = await AgentRunner.run(
agent, prompt,
output_validators=[BoundedTextValidator("title", 255)],
max_corrections=1,
)
On a validation failure the agent is re-prompted up to max_corrections times;
if it still fails, each validator's deterministic normalize() bounds the value.
Status
0.2.0 ships the execution engine, the ModelClientProvider seam, and the
batteries-included OpenRouter provider (single OPENROUTER_API_KEY, all
model families) so adopters can start without writing a provider.
License
MIT.
Metadata
Release files for boundless-agentrunner 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| boundless_agentrunner-0.2.2.tar.gz | 48.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| boundless_agentrunner-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 86.3 kB
Release files / boundless_agentrunner-0.2.2.tar.gz
| Download URL | boundless_agentrunner-0.2.2.tar.gz |
|---|---|
| Size | 48.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2da46a741305b3242481581fa8d0d80660caacb016fe5a572e6eec72c8a98796
|
|
BLAKE2b-256 checksum How to use checksums |
0658a0b3e22bdf3a82ca1fcc2cf6f4d6c21b327d944999ed43c92eb9126a871c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 Aug 1, 2026.
Transparency logRelease files / boundless_agentrunner-0.2.2-py3-none-any.whl
| Download URL | boundless_agentrunner-0.2.2-py3-none-any.whl |
|---|---|
| Size | 38.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
601270fa8884668385cd9ce6ffa7dc98a5ce2ffdecb68728ac56538804e90a6d
|
|
BLAKE2b-256 checksum How to use checksums |
bfcfc079ed28a0750112615761f99872172d98acf62adc0c092de833ac631767
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 Aug 1, 2026.
Transparency logSecurity for boundless-agentrunner 0.2.2
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 2 files in this release have been uploaded with provenance metadata.
Attestation for boundless_agentrunner-0.2.2.tar.gz
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 Aug 1, 2026.
Transparency logA 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.