Skip to main content
The Python SDK ships in v0.1.4 — the public launch milestone. Today you can already enforce process-level timeout and step limits on any Python process using nanny run. Per-function cost metering and custom rules require the SDK. See the Quickstart.
The Python SDK brings the same enforcement model as the Rust SDK to Python — @tool, @rule, and @agent decorators that enforce limits per function call.

What’s coming

from nanny import tool, rule, agent, PolicyContext

@tool(cost=10)
def fetch_page(url: str) -> str:
    import httpx
    return httpx.get(url).text

@rule("no_spiral")
def check_spiral(ctx: PolicyContext) -> bool:
    h = ctx.tool_call_history
    return not (len(h) >= 3 and len(set(h[-3:])) == 1)

@agent("researcher")
def run_research(topic: str) -> list[str]:
    # Runs under [limits.researcher] from nanny.toml
    ...
Run it under enforcement exactly as you would any other process:
nanny run
When running outside nanny run, all decorators are no-ops — the functions execute normally with zero overhead.

Install (v0.1.4)

pip install nanny-sdk

Want to be notified?

Watch the GitHub repository for the v0.1.4 release. The Python SDK is the public launch milestone for Nanny — Python is where the majority of agent development happens today.