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.4.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.4.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lodestar_autogen-0.4.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lodestar_autogen-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f957b9c7f08a6d4dd7261886e20bd5c3a5e35c2023a725ba1792253f5a16482c
MD5 d76f42f1b48a559392ee06b911b67613
BLAKE2b-256 4b7faaabc2eff8999fe7aa97ec02c238a3006b87e9bea8c648776240d914ecbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for lodestar_autogen-0.4.0.tar.gz:

Publisher: publish-pypi.yml on qmilab/lodestar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for lodestar_autogen-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02ea1f255ca10f5c1a6f01fee5b0629040d31b00dac83b859fc04b1656e7b191
MD5 81fbe21e472c856671782ce6a48c208c
BLAKE2b-256 f2d00ad648d073eb3e5f0445c470a9df490900ba8359d2ac7e00ad8da9944392

See more details on using hashes here.

Provenance

The following attestation bundles were made for lodestar_autogen-0.4.0-py3-none-any.whl:

Publisher: publish-pypi.yml on qmilab/lodestar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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