Skip to main content

criticalbridge

Python SDK for building governed external agents on CriticalBridge. Boots the conformance sidecar in-process via subprocess, dispatches A2A /tasks to 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
  • /tasks dispatcher — local HTTP server, routes A2A envelopes to the right @handler
  • respond() — builds the A2A response AND queues a decision-lineage emit (NAIC V2 wire shape via cb-conformance)
  • Live session — agent.session reads 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.

Metadata

Release files for criticalbridge 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for criticalbridge 1.0.2
File Size Uploaded Provenance Actions
criticalbridge-1.0.2.tar.gz 55.2 kB With provenance Details for criticalbridge-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for criticalbridge 1.0.2
File Interpreter ABI Platform Actions
criticalbridge-1.0.2-py3-none-any.whl Python 3 none any Details for criticalbridge-1.0.2-py3-none-any.whl

Total release size: 113.7 kB

Release files / criticalbridge-1.0.2.tar.gz

Download URL criticalbridge-1.0.2.tar.gz
Size 55.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ff0183422e8e0e1d909419921881c5057a6b3277b031461ae6b2f5d11f461949
BLAKE2b-256 checksum
How to use checksums
34fea8d25ff3e14d31518ebd0ea863d802fd91a2c87e8963c3b94972b1423134
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.

Transparency log

Release files / criticalbridge-1.0.2-py3-none-any.whl

Download URL criticalbridge-1.0.2-py3-none-any.whl
Size 58.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba0218632241c624b39ee99f9aa9487f821f9e1dd96b40229f5ad92c9781b83f
BLAKE2b-256 checksum
How to use checksums
2365694e4c0010b513c4fa4eea035f3e7193dbc1c281f10d3806f278aeace34b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.

Transparency log

Security for criticalbridge 1.0.2

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for criticalbridge-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 12, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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