Python SDK for building governed external agents on CriticalBridge — boots the conformance sidecar, dispatches A2A tasks to your handlers, auto-emits decision lineage.
Project description
criticalbridge
Python SDK for building governed external agents on CriticalBridge. Boots the conformance sidecar in-process via subprocess, dispatches A2A
/tasksto your handlers, and auto-emits decision lineage to the Brain. The Python side of the integration described in the External Agent Integration Guide.
Install
pip install criticalbridge
v0.1 requires Node.js (>=20) on PATH — the SDK spawns the TypeScript sidecar (@criticalbridge/conformance-sidecar) as a subprocess via npx. v0.2 will ship a standalone binary that removes this dependency.
Hello-world agent
import os
from criticalbridge import ManagedAgent
agent = ManagedAgent(
brain_base_url="https://api.criticalbridge.ai",
enrollment_token=os.environ["CB_ENROLLMENT_TOKEN"],
entity_id="acme-corp",
agent_id="customer-support-langchain-v2",
vendor="langchain",
public_url="https://sidecar.acme.example.com", # HTTPS, what the Brain dispatches to
)
agent.start() # boots the sidecar; blocks until /healthz green
@agent.handler("customer.read")
def lookup_customer(request, context):
# business logic — call your model, your CRM, whatever
customer = {"id": request["customer_id"], "name": "Sample"}
return agent.respond(
action="return_customer_info",
payload=customer,
model_invocation={"model": "gpt-4o", "promptTokens": 412, "completionTokens": 87},
risk_tier="low",
)
agent.serve() # blocks until SIGINT
What the SDK gives you
- Sidecar lifecycle — spawn, wait-for-ready, graceful teardown on SIGINT /
atexit /tasksdispatcher — local HTTP server, routes A2A envelopes to the right@handlerrespond()— builds the A2A response AND queues a decision-lineage emit (NAIC V2 wire shape viacb-conformance)- Live session —
agent.sessionreads the registration JWT fresh from the sidecar each time (so E2 token refreshes are picked up without a restart)
Configuration
ManagedAgent(...) accepts these kwargs (validated at construction time; bad config raises BadConfigError before any I/O):
| Field | Required | Notes |
|---|---|---|
brain_base_url |
yes | e.g. https://api.criticalbridge.ai |
entity_id |
yes | Your CriticalBridge entity |
enrollment_token |
yes | One-time token from Portal /dashboard/managed-agents/enrollment-tokens |
agent_id |
yes | Durable per-agent ID within the entity |
vendor |
no | One of langchain / autogen / crewai / semantic-kernel / haystack / other. Default other. |
public_url |
no | HTTPS URL the Brain dispatches to the sidecar. Required for production deploys. |
sidecar_port |
no | Sidecar's listen port (default 8080) |
local_port |
no | Local /tasks server port (default ephemeral) |
display_name |
no | Label in the Portal fleet view |
capability_tags |
no | List of capability strings |
Logging
import logging
logging.getLogger("criticalbridge").setLevel(logging.DEBUG) # everything
logging.getLogger("criticalbridge.sidecar").setLevel(logging.WARNING) # quiet sidecar passthrough
Set CB_LOG_LEVEL=DEBUG in the environment as a shortcut.
License
Apache-2.0 © Frank Burkitt and CriticalBridge.AI contributors.
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 criticalbridge-1.0.1.tar.gz.
File metadata
- Download URL: criticalbridge-1.0.1.tar.gz
- Upload date:
- Size: 54.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f0b62180404ef60172a7b7d3c2e4cf223833129ac4d3a0f3442426b00f649de
|
|
| MD5 |
d0ea738473eebe209eb510e2ea5213d0
|
|
| BLAKE2b-256 |
cc9431053652f6a8e9367cfe3543edcbfa1fd56f247b789c02781b140969f425
|
Provenance
The following attestation bundles were made for criticalbridge-1.0.1.tar.gz:
Publisher:
publish-criticalbridge-sdk.yml on fburkitt/CriticalBridgeApp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
criticalbridge-1.0.1.tar.gz -
Subject digest:
2f0b62180404ef60172a7b7d3c2e4cf223833129ac4d3a0f3442426b00f649de - Sigstore transparency entry: 2025132602
- Sigstore integration time:
-
Permalink:
fburkitt/CriticalBridgeApp@896d77a0361e7c8666a76e4bef4ba7d1da35ff34 -
Branch / Tag:
refs/tags/criticalbridge-v1.0.1 - Owner: https://github.com/fburkitt
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-criticalbridge-sdk.yml@896d77a0361e7c8666a76e4bef4ba7d1da35ff34 -
Trigger Event:
push
-
Statement type:
File details
Details for the file criticalbridge-1.0.1-py3-none-any.whl.
File metadata
- Download URL: criticalbridge-1.0.1-py3-none-any.whl
- Upload date:
- Size: 58.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a674da90ed9466f0c24bd47687805030a5c97fc2d8e68672eaf8938adcc80b93
|
|
| MD5 |
f25397df8ec574505b8b1c17f59cdee3
|
|
| BLAKE2b-256 |
1f8dc72ee35844924a7d6b4248c2b60a8685d323a65aa26effc3745944138aff
|
Provenance
The following attestation bundles were made for criticalbridge-1.0.1-py3-none-any.whl:
Publisher:
publish-criticalbridge-sdk.yml on fburkitt/CriticalBridgeApp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
criticalbridge-1.0.1-py3-none-any.whl -
Subject digest:
a674da90ed9466f0c24bd47687805030a5c97fc2d8e68672eaf8938adcc80b93 - Sigstore transparency entry: 2025132732
- Sigstore integration time:
-
Permalink:
fburkitt/CriticalBridgeApp@896d77a0361e7c8666a76e4bef4ba7d1da35ff34 -
Branch / Tag:
refs/tags/criticalbridge-v1.0.1 - Owner: https://github.com/fburkitt
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-criticalbridge-sdk.yml@896d77a0361e7c8666a76e4bef4ba7d1da35ff34 -
Trigger Event:
push
-
Statement type: