You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: sample external content gate around an approved text-fetch tool #9014
Add a focused Python FunctionMiddleware sample that checks the destination of one exact operator-approved HTTPS text-fetch URL, then inspects its complete result before another model call. It would live in python/samples/02-agents/middleware/ismalicious_content_gate.py, with a README entry and credential-free sample tests. No framework API, provider implementation, dependency set, or function-calling loop changes are proposed.
The example calls IsMalicious GET /gate/url before call_next() and POST /gate/scan after it. block and warn refuse release by default; an explicit operator option can release warn. HTTP/quota/timeout/schema failures and incomplete link inspection stop the run. The middleware replaces context.result with a fixed withholding message before MiddlewareTermination, because termination can otherwise preserve an already-produced result.
A local implementation is ready for review. Its 33 tests run the actual Agent function-calling loop and middleware layers with simulated HTTP and model responses. They cover ordering, no next model call after refusal, withholding in result/session, unchanged allowed text, exact original URL encoding, unknown link reputation, serialized body limits, invalid UTF-8 and credential-free decision logs. Ruff and the repository's relaxed sample Pyright configuration pass for the new files.
Scope and service disclosure
This is an external-service sample submitted from the IsMalicious project, prepared with AI assistance. Scans transmit the selected document's full text and URL to https://api.ismalicious.com and use its separate scan quota; credentials are required for a live run. Allowed content is retained unchanged. allow is not proof that content is benign, and the service currently maps unknown link reputation to allow.
The example covers one exact selected local tool, an exact operator-approved public URL and matching hostname, non-streaming Agent.run(), and complete UTF-8 text/plain or text/html results. MCP and provider-executed tools, binary/arbitrary object results and incremental results are explicitly outside its tested scope. No real API keys, external model calls or detector-accuracy claims are involved in the tests.
I intend to submit the prepared sample as a draft for feedback, following the middleware sample channel used by #6528. Please advise whether this scope and sample location fit the project before a maintainer considers merging it.
Thanks for the detailed proposal and for being upfront about the external-service scope. For now, we don't want to take on samples that call out to a specific third-party paid service like this inside the core samples tree, so we'll pass on merging PR #9015. We'd still welcome this as a community-maintained example linked from docs if there's a good home for it. Marking this as not planned for now — thanks again for the thorough write-up and tests.
It uses released framework packages with locked dependencies. All 43 credential-free tests pass through the actual function-calling and middleware layers, and the public CI passes. The README explains the paid-service requirements, outgoing URL/content data, scope and limitations; fixture tests are not a detector-accuracy or live-service claim.
Would a link in the community documentation be appropriate, and which location would you recommend?
Activity
eavanvalkenburg commentedon Oct 5, 2026
Thanks for the detailed proposal and for being upfront about the external-service scope. For now, we don't want to take on samples that call out to a specific third-party paid service like this inside the core samples tree, so we'll pass on merging PR #9015. We'd still welcome this as a community-maintained example linked from docs if there's a good home for it. Marking this as not planned for now — thanks again for the thorough write-up and tests.
hexablob commentedon Oct 6, 2026
Thanks for clarifying the core-samples policy. The sample now has an independent, community-maintained home: https://github.com/hexablob/ismalicious-agent-framework-example
It uses released framework packages with locked dependencies. All 43 credential-free tests pass through the actual function-calling and middleware layers, and the public CI passes. The README explains the paid-service requirements, outgoing URL/content data, scope and limitations; fixture tests are not a detector-accuracy or live-service claim.
Would a link in the community documentation be appropriate, and which location would you recommend?