Skip to content

Python: samples: hdp_provenance - cryptographic delegation audit trail for agent-framework agents#5727

Open
asiridalugoda wants to merge 4 commits intomicrosoft:mainfrom
asiridalugoda:feat/hdp-provenance-sample
Open

Python: samples: hdp_provenance - cryptographic delegation audit trail for agent-framework agents#5727
asiridalugoda wants to merge 4 commits intomicrosoft:mainfrom
asiridalugoda:feat/hdp-provenance-sample

Conversation

@asiridalugoda
Copy link
Copy Markdown

Summary

This PR adds python/samples/02-agents/security/hdp_provenance.py - a minimal (~50 line)
sample showing how to attach HDP (Human Delegation Provenance) to any agent-framework
Agent with a single middleware.configure(agent) call.

HDP creates a tamper-evident Ed25519 chain from the authorising human to every downstream
agent action. The chain is verifiable fully offline - no network call, no central registry.

What's included

One file, no changes to existing samples:

File Purpose
python/samples/02-agents/security/hdp_provenance.py Configure HDP on an agent, run it, verify chain offline

Why this matters for agent-framework users

Multi-agent systems have no standard way to prove that a downstream action was authorised
by a specific human. HDP fills that gap: a compact, self-contained token that any verifier
can validate with just a public key.

This integration was first validated with AutoGen:

No HDP internals included

The entire HDP implementation lives behind pip install hdp-agent-framework. The sample
contains zero crypto, zero token format detail - only the integration surface.

Test plan

  • pip install "agent-framework-core" "hdp-agent-framework" python-dotenv
  • Generate key: see comment at top of file
  • python hdp_provenance.py - verify HDP chain valid: True in output

References

Copilot AI review requested due to automatic review settings May 9, 2026 08:06
@moonbox3 moonbox3 added the python label May 9, 2026
@github-actions github-actions Bot changed the title samples: hdp_provenance - cryptographic delegation audit trail for agent-framework agents Python: samples: hdp_provenance - cryptographic delegation audit trail for agent-framework agents May 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Python security sample demonstrating how to attach and verify an HDP (Human Delegation Provenance) cryptographic delegation chain for an agent_framework.Agent via a single middleware configuration call.

Changes:

  • Introduces hdp_provenance.py sample that configures HdpMiddleware, runs an agent, exports the resulting token, and verifies the delegation chain offline.
  • Includes local key-loading logic and a one-time key generation snippet for Ed25519.

Comment thread python/samples/02-agents/security/hdp_provenance.py Outdated
Comment thread python/samples/02-agents/security/hdp_provenance.py Outdated
Comment thread python/samples/02-agents/security/hdp_provenance.py
@asiridalugoda
Copy link
Copy Markdown
Author

Thanks for the review. Fixed in the latest commit:

  • Install deps: updated to agent-framework-foundry (for FoundryChatClient), azure-identity, and hdp-agent-framework (which pulls in cryptography transitively)
  • Base64 padding: replaced the fixed "==" with "=" * (4 - len(raw_b64) % 4) % 4 to correctly normalise any input length
  • AzureCliCredential: switched to the synchronous import from azure.identity to avoid the unclosed aiohttp session

@moonbox3 moonbox3 added the documentation Improvements or additions to documentation label May 9, 2026
@asiridalugoda
Copy link
Copy Markdown
Author

@moonbox3 thanks for the tags. I've updated the readme and closed copilot comments. 👍

Adds inline tamper-detection check: mutate a hop signature and show
verify_chain returns valid=False at the first corrupt hop. Documents
max_hops failure semantics and strict-vs-audit mode as annotated comments.

Addresses review feedback from PR discussion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants