Skip to main content

autarkia

Tool governance for AI agents — a registry, risk levels, role-based access, visibility rules, and execution guards for LLM tool calling.

This is the tool layer of Autarkia, a self-hosted agent runtime that has run on a single machine for months: around 90 tools across 20+ domains, isolated per role, with pre-execution permission checks — not prompt promises.

Why

Most agent frameworks answer "how do I call a tool". This library answers the question that shows up after your agent has been running for a while: who is allowed to call what, and what happens before it runs.

  • Registry — one place for tool instances, runtime enable/disable, and stable OpenAI function-calling schemas (byte-stable output so API-side prompt caches keep hitting).
  • Declared risk levels — every tool carries an explicit risk class (read, write, external_write, device_read, device_control, sensitive). If you forgot to declare one, it simply does not appear in discovery. Risk is never inferred.
  • Role policies — resident / on-demand / disabled per role, plus keyword routing for the first turn. A role that was never granted a tool cannot see it, search for it, or call it.
  • Visibility rules — persona-level allow/deny by name or category, with mode and sensitive-mode overlays.
  • Execution guard — authorization against the request's own snapshot, argument validation, and per-call context isolation (no shared mutable tool state across concurrent roles).

Zero runtime dependencies beyond pydantic. No framework lock-in: tools are plain classes, the registry is a plain object, and the OpenAI-compatible schema export works with any API that speaks function calling.

Install

pip install autarkia

Quick start

from pydantic import BaseModel

from autarkia.tools import BaseTool, ToolCatalog, ToolDeclaration, ToolRegistry


class EchoArgs(BaseModel):
    text: str

class EchoTool(BaseTool):
    name = "echo"
    description = "Echo the given text back."
    args_schema = EchoArgs

    async def _run(self, text: str) -> str:
        return text


# Declare what each tool is allowed to be. Undeclared tools stay invisible.
catalog = ToolCatalog()
catalog.declare(
    "echo",
    ToolDeclaration(
        domain="utility",
        risk_level="read",
        load_policy="base",
        tags=("demo", "echo"),
    ),
)

registry = ToolRegistry(catalog=catalog)
registry.register(EchoTool())

# OpenAI function-calling format, cached and byte-stable.
print(registry.get_openai_tools())

Role-based access

from autarkia.tools import RolePolicyResolver

profiles = {
    "defaults": {"on_demand": ["domain:*"]},
    "roles": {
        "librarian": {"resident": ["echo"], "disabled": ["domain:execution"]},
    },
    "modes": {},
    "routes": [
        {"keywords": ["repeat"], "tools": ["echo"]},
    ],
}

resolver = RolePolicyResolver(profiles, catalog=catalog)
policy = resolver.resolve(scope="librarian")
policy.allows("echo")        # True
policy.allows("run_code")    # False — disabled for this role

picked = resolver.select("please repeat this", scope="librarian")

Execution guard

import asyncio
from autarkia.tools import execute_tool_call

result = asyncio.run(execute_tool_call(
    agent=agent,                 # any object exposing .tool_registry
    tool_name="echo",
    arguments={"text": "hi"},
    user_id="user-1",
    allowed_tool_names=policy.visible_tool_names(),
))

The guard never trusts the model: it checks the tool against the allowed list passed by the orchestrator, validates arguments, and copies the tool instance so concurrent roles cannot bleed state into each other.

Concepts

Piece File What it decides
BaseTool autarkia.tools.base what a tool is (name, args schema, category)
ToolCatalog / ToolDeclaration autarkia.tools.metadata domain, tags, risk level, load policy — declared per tool
ToolRegistry autarkia.tools.registry registration, enable/disable, schema export, discovery search
RoleToolPolicy / RolePolicyResolver autarkia.tools.policy resident / on-demand / disabled per role, keyword routing
filter_tool_names autarkia.tools.visibility persona allow/deny, mode and sensitive-mode overlays
execute_tool_call autarkia.tools.execution the last line of defense before a tool runs

Risk levels: read → write → external_write → device_read → device_control → sensitive. Load policies: base (always offered), on_demand (found through discovery), hidden (exists, never advertised).

The bigger picture

Autarkia itself is not on PyPI — it is a single-machine runtime, not a SaaS. This package ships the governance layer that survived that experiment, because it turned out to be the part other projects kept asking for.

License

MIT

Metadata

Release files for Autarkia 0.1.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 Autarkia 0.1.0
File Size Uploaded Provenance
autarkia-0.1.0.tar.gz 19.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 37.4 kB

Release files / autarkia-0.1.0.tar.gz

Download URL autarkia-0.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3168a0d30a0b625cd9111f17a83756dd8fd07f1cc76d60e31d4e9551fb3a636f
BLAKE2b-256 checksum
How to use checksums
21af12d5fbee45075e07ba91a176852e000b7c0c8997c209129c4e4e43394870
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / autarkia-0.1.0-py3-none-any.whl

Download URL autarkia-0.1.0-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0eab1455d6598017c54faf1de3d286b2334c5e543c2aef8903ff23221b438c4
BLAKE2b-256 checksum
How to use checksums
a8e6950020b552969238894bb5f1754ac9b625280080628fa85942158bffbf36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for Autarkia 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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