Skip to main content

HDP (Human Delegation Provenance) middleware for AutoGen — cryptographic audit trail for multi-agent delegation

Project description

hdp-autogen

HDP (Human Delegation Provenance) middleware for AutoGen — attach a cryptographic audit trail to any multi-agent conversation with zero changes to your existing code.

Every speaker turn in an AutoGen GroupChat is recorded in a tamper-evident chain of Ed25519 signatures, verifiable offline with a single public key.

pip install hdp-autogen

Quick start

from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from autogen import ConversableAgent, GroupChat, GroupChatManager
from hdp_autogen import HdpMiddleware, HdpPrincipal, ScopePolicy, verify_chain

# 1. Your signing key (store in a secrets manager, never in code)
private_key = Ed25519PrivateKey.generate()

# 2. Define what the human is authorising
scope = ScopePolicy(
    intent="Coordinate research agents to summarise recent papers",
    authorized_tools=["web_search", "file_reader"],
    max_hops=10,
)

# 3. Create the middleware
middleware = HdpMiddleware(
    signing_key=private_key.private_bytes_raw(),
    session_id="research-2026-q1",
    principal=HdpPrincipal(id="researcher@lab.edu", id_type="email"),
    scope=scope,
)

# 4. Build your agents as normal
researcher = ConversableAgent("researcher", ...)
reviewer = ConversableAgent("reviewer", ...)
groupchat = GroupChat(agents=[researcher, reviewer], messages=[])
manager = GroupChatManager(groupchat=groupchat, ...)

# 5. Attach HDP — one line, zero agent changes
middleware.configure(manager)
manager.run_chat(messages=[{"role": "user", "content": "Summarise recent LLM papers"}])

# 6. Verify the delegation chain offline
result = verify_chain(middleware.export_token(), private_key.public_key())
print(result.valid, result.hop_count, result.violations)

Five design considerations

# Consideration How it's handled
1 Scope enforcement Incoming messages are inspected for tool calls against authorized_tools. Default: logs + records violation in token. strict=True: raises HDPScopeViolationError.
2 Delegation depth ScopePolicy(max_hops=N) enforced per conversation; hops beyond the limit are skipped and logged.
3 Token size / performance Ed25519 signatures are 64 bytes each (~2.6 KB for a 10-hop chat). All HDP operations are non-blocking — failures log as warnings, agents always continue.
4 Verification verify_chain(token, public_key) validates root + every hop signature offline. Returns VerificationResult with valid, hop_count, violations, and per-hop outcomes.
5 GroupChat integration configure() detects ConversableAgent vs GroupChatManager and attaches the appropriate hooks. Each speaker turn = one delegation hop.

API reference

HdpMiddleware

HdpMiddleware(
    signing_key: bytes,          # Ed25519 private key (raw 32 bytes)
    session_id: str,             # unique ID for this conversation
    principal: HdpPrincipal,     # the human delegating authority
    scope: ScopePolicy,          # what is authorised
    key_id: str = "default",     # label stored in the token header
    expires_in_ms: int = 86400000,
    strict: bool = False,        # True → raise on scope violations
)
Method Description
configure(target) Attach hooks to a ConversableAgent, GroupChatManager, or list of agents
export_token() Return the token dict (or None before first message)
export_token_json() Return the token as a JSON string

verify_chain(token, public_key)

result = verify_chain(token_dict, public_key)  # Ed25519PublicKey or raw bytes
result.valid        # bool
result.hop_count    # int
result.violations   # list[str]
result.hop_results  # list[HopVerification]

ScopePolicy

ScopePolicy(
    intent: str,
    data_classification: str = "internal",   # "public" | "internal" | "confidential" | "restricted"
    network_egress: bool = True,
    persistence: bool = False,
    authorized_tools: list[str] | None = None,
    authorized_resources: list[str] | None = None,
    max_hops: int | None = None,
)

Error handling

By default, HDP middleware is non-blocking — signing or scope-check failures are logged as warnings and the agent continues normally. Violations are recorded in the token's hop metadata for post-hoc audit.

# Default (non-blocking): violations are logged, agents keep running
middleware = HdpMiddleware(
    signing_key=key, session_id="s1",
    principal=HdpPrincipal(id="alice", id_type="handle"),
    scope=ScopePolicy(intent="research", authorized_tools=["web_search"]),
)
middleware.configure(agent)
# If the agent calls an unauthorised tool (e.g. "execute_code"),
# → WARNING is logged, violation attached to the hop record
# → agent execution is NOT interrupted

# Strict mode: violations raise immediately
middleware_strict = HdpMiddleware(
    signing_key=key, session_id="s1",
    principal=HdpPrincipal(id="alice", id_type="handle"),
    scope=ScopePolicy(intent="research", authorized_tools=["web_search"]),
    strict=True,
)
middleware_strict.configure(agent)
# If the agent calls "execute_code" → raises HDPScopeViolationError

After a session, inspect violations via the token:

token = middleware.export_token()
for hop in token["delegation_chain"]:
    if hop.get("violation"):
        print(f"Hop {hop['seq']}: {hop['violation']}")

Cross-language compatibility

Python and TypeScript HDP tokens use the same wire format (RFC 8785 canonical JSON + Ed25519). A token issued by hdp-autogen (Python) can be verified by @helixar_ai/hdp (TypeScript) and vice versa — useful in mixed environments where some agents run in Python and others in Node.js.

# Python: export token
token_json = middleware.export_token_json()
# → pass to TypeScript service via API, message queue, etc.
// TypeScript: verify a token issued by Python
import { verifyChain } from "@helixar_ai/hdp";
const result = verifyChain(JSON.parse(tokenJson), publicKey);

Spec

Human Delegation Provenance (HDP) is an IETF draft: draft-helixar-hdp-agentic-delegation

License

CC BY 4.0 — Helixar Limited

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

hdp_autogen-0.1.2.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

hdp_autogen-0.1.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file hdp_autogen-0.1.2.tar.gz.

File metadata

  • Download URL: hdp_autogen-0.1.2.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hdp_autogen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c522c76cfc0face62be4d97cbc8c0c4afee4dfdb13ce215356727953c078196c
MD5 d8d9eabdfcb2dd371060179dbf864064
BLAKE2b-256 4523c86a1a097b57ccb4fcd48a8d662ff56fb89cddee29225182480c7a333927

See more details on using hashes here.

Provenance

The following attestation bundles were made for hdp_autogen-0.1.2.tar.gz:

Publisher: release.yml on Helixar-AI/HDP

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

File details

Details for the file hdp_autogen-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hdp_autogen-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hdp_autogen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ae017faab902c5dfd8d2a39f794bbb80d41175ba4e280c28a9242bb8c16e07de
MD5 08205a15d217c4332b98a3fed549a39b
BLAKE2b-256 63319650696963f3827d138415035958f64db7cbfb9c88a4e5f2e62133833b51

See more details on using hashes here.

Provenance

The following attestation bundles were made for hdp_autogen-0.1.2-py3-none-any.whl:

Publisher: release.yml on Helixar-AI/HDP

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