Python: Add an AgentFuse function middleware sample - #7719
Closed
Mkaliez (MkaliezZ) wants to merge 2 commits into
Closed
Python: Add an AgentFuse function middleware sample#7719Mkaliez (MkaliezZ) wants to merge 2 commits into
Mkaliez (MkaliezZ) wants to merge 2 commits into
Conversation
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 12:03 — with
GitHub Actions
Inactive
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 12:03 — with
GitHub Actions
Inactive
Mkaliez (MkaliezZ)
had a problem deploying
to
github-app-auth
August 18, 2026 12:03 — with
GitHub Actions
Error
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 12:03 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new Python sample demonstrating how to run AgentFuse policy checks as FunctionMiddleware before tool dispatch, plus documentation and a test that executes the sample’s contract verification.
Changes:
- Added
AgentFuseFunctionMiddlewaresample that preserves hostcall_id, fail-closes when guard evaluation fails, and returns a terminal “not executed” result for blocked calls. - Updated middleware samples README to list and describe the new sample.
- Added a pytest that imports/runs the sample and validates allow/block/fail-closed behavior (skipping when
dhms_agentfuseisn’t installed).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| python/samples/02-agents/middleware/agentfuse_function_middleware.py | Introduces AgentFuse-backed FunctionMiddleware sample and a self-verifying contract runner. |
| python/samples/02-agents/middleware/README.md | Documents the new middleware sample in the folder index. |
| python/packages/core/tests/core/test_agentfuse_function_middleware_sample.py | Adds coverage that imports and runs the sample’s contract verification + a missing-call_id fail-closed check. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 12:05 — with
GitHub Actions
Inactive
Mkaliez (MkaliezZ)
force-pushed
the
feat/agentfuse-function-middleware
branch
from
August 18, 2026 12:08
02f71d1 to
41595b9
Compare
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 12:08 — with
GitHub Actions
Inactive
Mkaliez (MkaliezZ)
force-pushed
the
feat/agentfuse-function-middleware
branch
from
August 18, 2026 12:09
41595b9 to
8852487
Compare
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 12:09 — with
GitHub Actions
Inactive
Author
|
@microsoft-github-policy-service agree |
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 13:09 — with
GitHub Actions
Inactive
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 13:11 — with
GitHub Actions
Inactive
Mkaliez (MkaliezZ)
marked this pull request as ready for review
August 18, 2026 13:11
Mkaliez (MkaliezZ)
temporarily deployed
to
github-app-auth
August 18, 2026 13:12 — with
GitHub Actions
Inactive
This was referenced Aug 18, 2026
Contributor
|
We're not going to add this to the repo at this time. Please feel free to host from your own repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Adds an optional PEP 723 sample showing how an external AgentFuse
RuntimeGuardcan use the existingFunctionMiddlewarepre-dispatch boundary. The sample preserves the hostcall_id, dispatches allowed calls, and returns a terminal non-execution result for policy blocks or guard evaluation failures.This is a concrete external-policy example of the execution-boundary middleware pattern discussed in #5366. It does not change framework APIs or default behavior.
Description & Review Guide
dhms-agentfuse==3.7.3version through PEP 723 metadata rather than adding a repository dependency.call_id, zero dispatch for block/evaluation failure, propagation of cancellation, and ownership of host-native execution errors after an allow decision.Related Issue
Fixes #7723
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.