General-purpose Python agent framework with pystator integration
Project description
PyGubernator
General-purpose Python agent framework with pystator integration: lifecycle state machines, LLM agents with tools, pipelines, Kafka/in-memory transport, and batch/stream runners.
Install
pip install pygubernator
Optional extras:
pip install pygubernator[llm] # LiteLLM provider
pip install pygubernator[kafka] # Kafka transport
pip install pygubernator[charter] # pycharter
pip install pygubernator[catalyst] # pycatalyst
pip install pygubernator[all]
Quick start
from pygubernator import Message, InMemoryTransport, run_stream
from pygubernator.agents import PipelineAgent
# … define agents and run run_stream / run_batch with a transport
Optional control-plane layers
pygubernator remains stateless at its core. Optional layers can be installed as extras:
pip install "pygubernator[api,db,postgres,ui]"
- API layer: FastAPI control plane (
pygubernator api, optional--host/--port/--no-reload) - Persistence layer: SQLAlchemy models + migrations under
src/pygubernator/db/ - UI layer: Next.js control plane (
pygubernator ui dev|serve|build, same flags as pycharter/pystator:--api-url,--host/--portforserve,--api-url/--portfordev)
Main control-plane routes:
/api/v1/agents(registry + versions + activation)/api/v1/runs(list/detail/control/replay, create runs via POST)/api/v1/observability(events/metrics/traces)/api/v1/policies(policy assignments/alerts/audit)
Registry-Driven Agents
PyGubernator supports a turnkey workflow where agents registered in the API can be instantiated and executed with automatic observability:
from pygubernator.spec import create_llm_agent_from_version
from pygubernator.runners import run_batch_with_db
from pygubernator.llm._provider import LiteLLMProvider
from pygubernator.db.session import SessionLocal
from pygubernator.db.models import AgentVersion
# Load version from database
db = SessionLocal()
version = db.get(AgentVersion, version_id)
# Create agent from stored metadata
agent = create_llm_agent_from_version(
version=version,
llm_provider_factory=lambda m: LiteLLMProvider(model=m or "gpt-4o-mini")
)
# Execute with automatic run lifecycle and event persistence
result = await run_batch_with_db(
agent=agent,
transport=transport,
topic="input",
db_session_factory=SessionLocal,
agent_id=version.agent_id,
agent_version_id=version.id
)
Key features:
- Spec / assembly (
pygubernator.spec): Build agents from version-like records (create_llm_agent_from_version) - Automatic run_id threading: Events automatically correlated to runs
- Convenience helpers:
run_stream_with_db/run_batch_with_dbmanage run lifecycle - HTTP client:
ControlPlaneClientfor API operations (optional) - Tool loading: Tools loaded from version metadata
See Integration Guide and Run Lifecycle for details.
Configuration
Settings can be loaded from environment variables with the prefix PYGUBERNATOR_, for example:
PYGUBERNATOR_AGENT_IDPYGUBERNATOR_LLM_MODELPYGUBERNATOR_KAFKA_BOOTSTRAP_SERVERSPYGUBERNATOR_KAFKA_GROUP_ID(default consumer group name:pygubernator)
Use AgentSettings.from_env() to populate AgentSettings.
For control-plane services, pygubernator also supports a pygubernator.cfg
file (same style as pycharter/pystator). Resolution order:
- environment variables
./pygubernator.cfg~/.pygubernator/pygubernator.cfg- project root config (near
alembic.ini)
See pygubernator.cfg.example for:
PYGUBERNATOR_DATABASE_URLPYGUBERNATOR_UI_THEME/PYGUBERNATOR_UI_APP_NAMEPYGUBERNATOR_AUTH_USERS/PYGUBERNATOR_AUTH_JWT_SECRET
Authentication bootstrap:
- Configure initial users in
PYGUBERNATOR_AUTH_USERS(env orpygubernator.cfg). - Set
PYGUBERNATOR_AUTH_JWT_SECRET(env orpygubernator.cfg) before using/api/v1/auth/login. - Use
Authorization: Bearer <token>for protected API routes (X-API-Tokenis not supported).
Development
make install-dev
make check
Git: ignored files must not be committed
.gitignore only affects untracked files. If something was committed before it was
ignored (or was added with git add -f), Git keeps tracking it until you remove it
from the index:
make git-untrack-ignored
# or: ./scripts/git-untrack-ignored.sh
git status # expect many "deleted" (index-only) paths — working tree unchanged
git commit -m "chore: stop tracking gitignored build/local files"
After that, git add and git commit will not re-add those paths. Keep using
pygubernator.cfg.example in the repo; copy to pygubernator.cfg locally (ignored).
Contributing and security
- CONTRIBUTING.md — dev setup, tests, and PRs
- SECURITY.md — reporting vulnerabilities privately
- CODE_OF_CONDUCT.md — community standards
Publishing
Version is managed with setuptools-scm. Prefer GitHub tag pushes (e.g. v0.1.0) and Trusted Publishing to PyPI; see .github/workflows/publish.yml and the Makefile publish / publish-test targets.
Rename note
This package was previously developed as pykairos. The PyPI distribution and import package are now pygubernator. Replace imports (import pygubernator), pip install pygubernator, and migrate environment variables from PYKAIROS_* to PYGUBERNATOR_*. The base exception type is GubernatorError (formerly KairosError).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygubernator-0.0.5.tar.gz.
File metadata
- Download URL: pygubernator-0.0.5.tar.gz
- Upload date:
- Size: 385.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f6331bbb338149ca206d9308162197f13b355c5a0c2d9e80c209dd26c07f909
|
|
| MD5 |
348971f829124486a8b14d057571a86b
|
|
| BLAKE2b-256 |
63eb698566eb9a2e0bc2acd05ca3b6338725e69199526fcba5951053645c6bef
|
Provenance
The following attestation bundles were made for pygubernator-0.0.5.tar.gz:
Publisher:
publish.yml on optophi/pygubernator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygubernator-0.0.5.tar.gz -
Subject digest:
8f6331bbb338149ca206d9308162197f13b355c5a0c2d9e80c209dd26c07f909 - Sigstore transparency entry: 1183508247
- Sigstore integration time:
-
Permalink:
optophi/pygubernator@982e3f9e0d16da3d37fbecc751a659290b42805a -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/optophi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@982e3f9e0d16da3d37fbecc751a659290b42805a -
Trigger Event:
push
-
Statement type:
File details
Details for the file pygubernator-0.0.5-py3-none-any.whl.
File metadata
- Download URL: pygubernator-0.0.5-py3-none-any.whl
- Upload date:
- Size: 418.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4184870a4cd839a0e5d0e59979a9658e9fa2bb8264b031bae5a37f6d58199a0
|
|
| MD5 |
d21b45b7970374fbb3cfb30a83f229e4
|
|
| BLAKE2b-256 |
0eb2d8bd86ab35138a0edd80c9256750911d20db426e52fbd1a7d0e7bf9f629b
|
Provenance
The following attestation bundles were made for pygubernator-0.0.5-py3-none-any.whl:
Publisher:
publish.yml on optophi/pygubernator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygubernator-0.0.5-py3-none-any.whl -
Subject digest:
e4184870a4cd839a0e5d0e59979a9658e9fa2bb8264b031bae5a37f6d58199a0 - Sigstore transparency entry: 1183508282
- Sigstore integration time:
-
Permalink:
optophi/pygubernator@982e3f9e0d16da3d37fbecc751a659290b42805a -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/optophi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@982e3f9e0d16da3d37fbecc751a659290b42805a -
Trigger Event:
push
-
Statement type: