Skip to main content

Govern an AutoGen agent's native tool calls with Lodestar — the thin native hook that remotes each tool call through the Lodestar Action Kernel over NDJSON-RPC (ADR-0027).

Project description

lodestar-autogen

Govern an AutoGen agent's native tool calls with Lodestar — the open epistemic-governance framework for AI agents.

AutoGen (the autogen-agentchat / autogen-core actor framework) runs multi-agent conversations whose tools are native in-process Python objects and does not speak MCP, so the MCP proxy cannot wrap it. This package is the thin native hook (ADR-0027) — the third framework on the same shared gate, after LangGraph and CrewAI: it spawns the TypeScript governance-gate sidecar (lodestar runtime gate) and remotes each native tool call through the Lodestar Action Kernel over newline-delimited JSON-RPC. The same machinery the MCP proxy and the LangGraph / CrewAI adapters run — two-phase propose → arbitrate → execute, the signed policy gate, cognitive-core ingestion (external-document content can't auto-promote), sentinel arbitration, and the signed-approval L4 hold path — now applies to AutoGen, with no change to the engine. The gate sidecar is shared, unchanged; only this hook is new.

The tool body runs only inside the gate's execute phase, reached only after the gate (and any approval hold) clears: "tools that do work before approval are bugs" — across the Python↔TS boundary.

Install

pip install "lodestar-autogen[autogen]"
# and the Lodestar CLI (Bun/npm), which provides `lodestar runtime gate`:
npm install -g @qmilab/lodestar-cli   # or: bun add -g @qmilab/lodestar-cli

Use

from autogen_agentchat.agents import AssistantAgent
from lodestar_autogen import GateClient, govern_tools, governed_call

with GateClient("runtime-gate.config.json") as gate:
    governed = govern_tools(gate, my_tools)        # register + wrap the toolset
    agent = AssistantAgent("assistant", model_client=model_client, tools=governed)
    # ... run your agent / team as usual; every tool call is governed.

    # A custom step invokes a governed tool through the helper, never raw.
    # It blocks, so off the event loop call it via a worker thread:
    import asyncio
    result = await asyncio.to_thread(governed_call, gate, "search_web", {"q": "lodestar"})

govern_tools accepts the same toolset shapes AssistantAgent does — a BaseTool as-is, or a bare callable (normalised to a FunctionTool using its docstring), so you can pass the literal tools=[my_func, ...] list you'd otherwise hand the agent.

The gate's config (runtime-gate.config.json) is a RuntimeGateConfig — the signed policy document, approver keys, sentinel ids, persistence, and durable log root all live there. The hook never holds credentials or policy.

Scope (honest, ADR-0004 lineage)

This is governance over declared actions, not OS containment of the process. Raw I/O performed outside the tool abstraction — a custom step that calls requests.get() directly instead of a registered tool — is outside the governed surface, exactly as guard.wrap() and the MCP proxy only govern the tools they are given. A call for an unregistered tool is denied (fail closed). Pair the adapter with network/filesystem controls for defense in depth.

Holds & denials

An L4 action the trust-ladder floor parks for approval is resolved by block-polling the gate up to the deadline for a signed approval (hold_wait_ms) — the headless default. A denied / held-then-timed-out call raises LodestarDenied by default; AutoGen's StaticWorkbench.call_tool catches it and surfaces the reason to the agent as a re-plannable error ToolResult. Pass on_denied to govern_tools to map a denial to a return value instead.

Async, loops & cancellation

AutoGen's tool surface is fully async (BaseTool.run_json is a coroutine). The governed wrapper offloads the blocking gate RPC onto a worker thread so it never stalls the agent's event loop, and the gate's remoted body runs the original tool's coroutine on a single persistent event loop — so loop-scoped state a tool caches (an aiohttp.ClientSession, an asyncio.Event) stays valid across calls rather than being bound to a loop that is torn down after each call.

The wrapper honours AutoGen's CancellationToken: an already-cancelled token short-circuits (no governed work starts), and an in-flight call is unblocked when the run is cancelled. Note that once the gate is executing the tool body it runs server-side and can't be force-cancelled mid-flight — a property of the remoted-execute model it shares with the LangGraph / CrewAI hooks.

Apache-2.0. Part of the Lodestar monorepo (runtimes/autogen/). The pure-stdlib client.py is duplicated verbatim from lodestar-langgraph / lodestar-crewai; it graduates to a shared lodestar-runtime-client package alongside PyPI publishing (issue #128).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lodestar_autogen-0.3.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lodestar_autogen-0.3.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file lodestar_autogen-0.3.0.tar.gz.

File metadata

  • Download URL: lodestar_autogen-0.3.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lodestar_autogen-0.3.0.tar.gz
Algorithm Hash digest
SHA256 83cc33e3ba351a0eea1633c95825414c476cfdbc53ea38185e60760d1e3af81c
MD5 ada9118f3d41bb0b987ae8bb752fce21
BLAKE2b-256 6bda688dda15592439c8da28cc24e88e7b840b968ef9a5121dc85704bf9a1610

See more details on using hashes here.

File details

Details for the file lodestar_autogen-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: lodestar_autogen-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lodestar_autogen-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d48b70589ae52a05f86ab7e2986e3e1140b846dad04638bdea9307c1c8cb99d
MD5 e3e8fb29c598ce9cc888f7f136b8fbbe
BLAKE2b-256 bc6bf616d7aaceaf13b84e39617e60b8f8f74c7b6b5b8569b884bd18af00df90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page