Repository navigation
Python: add task-scoped authority middleware sample - #10215
Open
aimable100 wants to merge 3 commits into
Open
aimable100 wants to merge 3 commits into
aimable100 wants to merge 3 commits into
Conversation
Adds a FunctionMiddleware sample where a coordinator delegates a billing ticket to a sub-agent with authority for one invoice and a refund ceiling. Calls outside that scope are denied before the tool body runs. Fixes microsoft#9470
aimable100
temporarily deployed
to
github-app-auth
November 9, 2026 22:35 — with
GitHub Actions
Inactive
2 tasks done
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Negative refund amounts can execute successfully, and the shared FoundryChatClient leaves owned connections unclosed on both success and failure.
2 open issues
What changed in this PR
Adds a Python sample for #9470 showing how existing FunctionMiddleware primitives enforce task-scoped authority for a delegated billing agent. Changes are limited to samples and documentation; no framework package code changes.
Changes:
- Uses Tenuo warrants to narrow delegated authority to one invoice and a refund ceiling.
- Demonstrates returning authorization denials to the model without executing the tool.
- Declares inline dependencies and adds the sample to the middleware index.
| File | Description |
|---|---|
python/samples/02-agents/middleware/task_scoped_authority_middleware.py |
Adds the delegation, authorization middleware, and refund demonstration. |
python/samples/02-agents/middleware/README.md |
Adds a link and description for the new sample. |
Review effort: Balanced
aimable100
temporarily deployed
to
github-app-auth
November 9, 2026 22:56 — with
GitHub Actions
Inactive
aimable100
temporarily deployed
to
github-app-auth
November 10, 2026 08:17 — with
GitHub Actions
Inactive
This branch was previously deployed
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 the sample discussed in #9470: a coordinator hands a sub-agent authority for one task only, and a
FunctionMiddlewareenforces it on every tool call. The existing middleware samples cover blocking known attack patterns and asking a human; this one covers the case in between, where the sub-agent may act but only within the scope of the ticket it was given.Maintainer direction is in #9470 (comment) ("this belongs in a sample using the existing
FunctionMiddlewareprimitives").Description & Review Guide
python/samples/02-agents/middleware/task_scoped_authority_middleware.py, and one row in that folder's README. No package code changes.tenuo(Apache-2.0) through PEP 723 inline metadata, so nothing is added to the dev environment.context.resultis set andcall_next()is skipped, so the tool body never runs and the model sees the reason), and whether the file is the right size for this folder.Checked with
uv run poe syntax -S,uv run poe pyright -Sanduv run poe test-typing -S; the new file is clean in each. Run end to end against a live model: the in-scope refund runs and the out-of-scope refund is denied before the tool body. I ran that withOpenAIChatClientswapped in, since I don't have a Foundry project to hand; the committed file usesFoundryChatClientlike the neighbouring samples.Related Issue
Fixes #9470
No other open PR exists for this issue.
AI Assistance
AI assistance details: implementation of the sample, the README row, and this PR description.
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.