Skip to main content

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 /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 sessionagent.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.

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

criticalbridge-1.0.0.tar.gz (54.0 kB view details)

Uploaded Source

Built Distribution

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

criticalbridge-1.0.0-py3-none-any.whl (57.8 kB view details)

Uploaded Python 3

File details

Details for the file criticalbridge-1.0.0.tar.gz.

File metadata

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

File hashes

Hashes for criticalbridge-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d891e81469f1d932f97740a97109be9074083b6d4b68058543163195770affb5
MD5 c2ef088157f8cd43c99739b684c2b302
BLAKE2b-256 c9271a6c1bf583531041c3446c485a722e0065622774e75093e5419d627ba86c

See more details on using hashes here.

Provenance

The following attestation bundles were made for criticalbridge-1.0.0.tar.gz:

Publisher: publish-criticalbridge-sdk.yml on fburkitt/CriticalBridgeApp

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

File details

Details for the file criticalbridge-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: criticalbridge-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 57.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for criticalbridge-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb37ff069632dda32e0dc70f0dd944f4d7de8dcc45386f46188ee6f4d73b53f7
MD5 b640d46f02b33507af1e9c24262a41e8
BLAKE2b-256 fa67fe1124a9c00d15a36633f9929dfa5cd5d95e5b7e786383fa77ee5b38c6ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for criticalbridge-1.0.0-py3-none-any.whl:

Publisher: publish-criticalbridge-sdk.yml on fburkitt/CriticalBridgeApp

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