Skip to main content

ExecutionKit

Async Python functions for repeatable LLM call patterns, tool loops, and small execution workflows.

Python 3.11-3.13 License: MIT PyPI CI Docs

ExecutionKit sits between a raw chat-completions call and a workflow runtime. It provides bounded functions for common call patterns, plus small helpers for cost tracking, retries, approvals, routing, checkpoints, tracing, and evaluation.

Use it when your application already owns the surrounding service and needs a few well-defined LLM execution functions. Do not use it as a retrieval system, long-running scheduler, provider gateway, or multi-agent runtime. See Scope for the boundary.

The base install supports Python 3.11 through 3.13 and has no required third-party runtime dependencies.

Release status

python -m pip install executionkit currently installs 0.4.0 (released 2026-09-23), which includes the Claude Agent SDK transport and the two RetryConfig/react_loop() behavior changes described below. The full, commit-traceable list is the [0.4.0] section of CHANGELOG.md.

Install

python -m pip install executionkit

Optional extras add only the feature you request:

python -m pip install "executionkit[httpx]"       # pooled HTTP connections
python -m pip install "executionkit[jsonschema]"  # full tool-argument validation
python -m pip install "executionkit[otel]"        # OpenTelemetry API integration
python -m pip install "executionkit[claude]"      # Claude Agent SDK transport

First call

import asyncio
import os

from executionkit import Provider, consensus


async def main() -> None:
    async with Provider(
        base_url="https://api.openai.com/v1",
        api_key=os.environ["OPENAI_API_KEY"],
        model=os.environ["OPENAI_MODEL"],
    ) as provider:
        result = await consensus(
            provider,
            "Return only the ISO country code for France.",
            num_samples=3,
        )
        print(result.value)
        print(result.metadata["agreement_ratio"])
        print(result.cost)


asyncio.run(main())

Expected output (token counts depend on the endpoint; the shape does not):

FR
1.0
TokenUsage(input_tokens=..., output_tokens=..., llm_calls=3)

result.cost.llm_calls counts dispatched HTTP attempts, including retries. For example, three samples cost three calls only when none of the samples is retried.

See the quick start for local-provider setup, synchronous wrappers, and the other patterns.

Patterns

Function Use it for
consensus() Run several independent calls and measure exact-answer agreement.
refine_loop() Generate, score, and revise until a score target or iteration limit is reached.
react_loop() Let a model request registered async tools inside a bounded loop.
structured() Parse a JSON object or array, validate it, and request repairs when needed.
pipe() Pass one pattern result into the next and keep one shared budget.
map_reduce() Process independent inputs concurrently, then combine the mapped results.

Async functions are the primary API. Matching _sync wrappers are available for all six patterns in code that does not already run an event loop.

Every pattern returns PatternResult:

result.value       # pattern output
result.score       # optional pattern-specific score
result.cost        # TokenUsage(input_tokens, output_tokens, llm_calls)
result.metadata    # read-only pattern-specific metadata

Execution helpers

Area Public API
Provider access Provider, LLMProvider, ToolCallingProvider, StreamingProvider
Session state Kit
Retry and rate control RetryConfig, TokenBucket
Cost accounting TokenUsage, CostTracker, estimate_cost()
Routing Router, RouteRule
Dependency-ordered work Workflow, Step, WorkflowCheckpoint
Ordered plans Plan, PlanStep
Approval ApprovalGate, ApprovalRequest, ApprovalDecision
Tracing TraceEvent, TraceCallback
Evaluation EvalCase, EvalReport, ConversationScript, run_eval_suite()

These helpers run inside one process. They do not provide durable scheduling, distributed coordination, or multi-agent handoff.

Versioned retry guidance. RetryConfig.max_retries means something different depending on which version you run:

You have max_retries means A failing call with max_retries=3 makes
0.3.0 and earlier The total number of attempts, retries included 3 attempts
0.4.0 (pip install executionkit today) Retries after the initial call 4 attempts (1 + 3)

The 0.4.0 behavior also makes RetryConfig agree with structured()'s own max_retries, which has always run 1 + max_retries attempts, and it rejects a negative max_retries with ValueError instead of silently making zero attempts. To keep 0.3.0's call count exactly when you upgrade, decrement existing max_retries values by one (max_retries=N → max_retries=N-1); max_retries=0 is unchanged either way — always a single attempt, no retries. See the [0.4.0] section of CHANGELOG.md for the full migration note, including a max_cost budget edge case.

Provider contract

Provider sends bearer-authenticated requests to an OpenAI-compatible /chat/completions endpoint. Set base_url, api_key, and model for the endpoint you use:

provider = Provider(
    base_url="http://localhost:11434/v1",
    model="your-local-model",
)

You can also pass any object that implements the LLMProvider protocol. A custom adapter does not need to inherit from an ExecutionKit class.

Provider compatibility varies by endpoint and model. In particular, tool calling and streaming work only when the endpoint returns the corresponding OpenAI-format fields. The provider guide lists the exact contract and current endpoint examples.

Tool execution boundary

react_loop() executes only the Tool objects registered by the caller. The loop applies these controls before and around each tool call:

  • tool names must be unique — enforced with a ValueError before the first provider call (0.4.0+; on 0.3.0 and earlier a duplicate name silently shadows the earlier tool instead of raising);
  • arguments are checked against a dependency-free JSON Schema subset;
  • schemas outside that subset fail closed unless the jsonschema extra is installed;
  • each tool has a timeout;
  • calls per round, rounds per run, and observation length are bounded;
  • an optional ApprovalGate can reject a call before its body runs; and
  • tool exceptions become bounded observations containing the exception type, not the exception message or traceback.

This protects the model-to-tool boundary. It does not isolate the Python code inside a tool. Run untrusted tool implementations in a separate process or container owned by your application.

MCP and batch integrations

python -m executionkit.mcp starts a standard-library-only MCP server over stdio. It exposes consensus and a react_loop limited to the package's fixed demo tools. It does not expose arbitrary caller-defined Python functions.

AnthropicBatchClient, consensus_batch(), and map_batch() use Anthropic's Message Batches API for offline fan-out jobs. This integration is Anthropic-specific and separate from the OpenAI-compatible Provider.

Read the MCP guide and Message Batches guide before using either integration.

Scope

ExecutionKit intentionally does not provide:

  • retrieval, embeddings, or vector storage;
  • persistent or distributed workflow scheduling;
  • dashboards or spend-management services;
  • native adapters for every model provider; or
  • multi-agent coordination.

The companion agentic-runtime-platform owns the higher-level runtime concerns. ExecutionKit remains usable on its own.

Documentation

Development

python -m pip install -e ".[dev,docs]" pip-audit
python -m ruff check executionkit tests scripts
python -m ruff format --check executionkit tests scripts
python -m mypy --strict executionkit
python scripts/check_doc_facts.py
python scripts/check_lock_parity.py
python -m pytest -q
python -m mkdocs build --strict

See CONTRIBUTING.md for platform-specific setup and the optional security checks.

License

MIT. See LICENSE.

Metadata

Release files for executionkit 0.4.0

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

Source distribution (sdist)

Source distribution for executionkit 0.4.0
File Size Uploaded Provenance
executionkit-0.4.0.tar.gz 641.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for executionkit 0.4.0
File Interpreter ABI Platform
executionkit-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 756.5 kB

Release files / executionkit-0.4.0.tar.gz

Download URL executionkit-0.4.0.tar.gz
Size 641.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f3dc1ebc128a7dceb372d1f613fb1111a800ef7d533f1d956a98f695ed16d1a9
BLAKE2b-256 checksum
How to use checksums
aa78bf0afae5083fd31e67280c8c0b6ab6dcdd2949f2647fdd0ab381c12033f7
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 Sep 23, 2026.

Transparency log

Release files / executionkit-0.4.0-py3-none-any.whl

Download URL executionkit-0.4.0-py3-none-any.whl
Size 114.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23e28507b5f4d94512b1fb576671f2b3d0e81b3508c4dd8049dc7ec7f781e57a
BLAKE2b-256 checksum
How to use checksums
b61162bb8a3d76c2de0acbe7c53a127f834d242fe7fbf03e43b2b0c7a9c5e019
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 Sep 23, 2026.

Transparency log

Security for executionkit 0.4.0

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.

Select from 2 files

Attestation for executionkit-0.4.0.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 Sep 23, 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