feat: implement pluggable taxonomy and policy security plugin#151
Open
ViktorVeselov wants to merge 6 commits into
Open
feat: implement pluggable taxonomy and policy security plugin#151ViktorVeselov wants to merge 6 commits into
ViktorVeselov wants to merge 6 commits into
Conversation
This was referenced May 29, 2026
Author
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.
Have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Link to an existing issue / related PR:
adk-python-community: feature: pluggable policy & taxonomy for more accurate and more deterministic skill/tool execution #152adk-python): feat: add pluggable policy & taxonomy adk-python#5898adk-python: feat: add pluggable policy & taxonomy adk-python#5898 (Closed on core to release as a pluggable community package) and marked withcommunity-repotag.adk-python: [RFC] Taxonomy-Driven Skill Routing & Dynamic Context Mutation adk-python#5891adk-pythonfeature: Modular Domain Taxonomy adk-python#5895 that was transferred toadk-python-communityas per the request of Rahityan's suggestion/recommendation: feat: add pluggable policy & taxonomy adk-python#5898 (comment)Problem:
Developers and system administrators need a robust, standardized way to enforce security policies and access controls on skills based on organizational hierarchies and taxonomies (e.g., flat department structures or rich SKOS JSON-LD classifications).
Originally, we designed this to be embedded directly into the core
adk-pythonSDK. However, in line with keeping the core framework minimalist, light, and secure, the core reviewers pointed me here to implement this as an official community extension plugin (referencing the closed PR adk-python/pull/5898).Solution:
Implemented the Taxonomy & Policy Security Engine as a pluggable, opt-in plugin (
TaxonomyPlugin) inadk-python-community. This gives developers enterprise-grade taxonomy controls and skill-access guardrails without cluttering the core SDK. Additionally, it can be used as a tool for usage reinforcers and for dynamic prompting that helps to provide an agent with well-polished context, skills/tools executions tailored toward determined cases.Key design points include:
_get_taxonomy_binds()pattern to readtaxonomy-bindskeys fromFrontmatter.model_extra(natively populated because the core SDK'sFrontmattermodel hasextra="allow"). This ensures perfect runtime compatibility with the unmodified coreadk-pythonlibrary.before_tool_callbackinstead of importing private core helper functions, making the plugin entirely resilient against future internal changes in core SDK versions.TaxonomyRegistryparses both standard Flat Key-Value JSON (id/parentId/name/definition) and rich JSON-LD with SKOS (Concept,prefLabel,altLabel,definition,broader) standards to resolve organizational hierarchies.TaxonomyPipelineandTaxonomyResolverinterfaces to dynamically chain multiple contextual policy resolvers (e.g., checking active user directories, roles, and entitlements) during runtime execution.BasePluginlifecycle callbacks to intercept tool boundaries (list_skills,load_skill, etc.), returning filtered lists in the expected dictionary-wrapped XML response structure.shape_system_instruction(), the plugin dynamically tailors the global agent instructions at runtime based on active user context and classifications (e.g., automatically injecting compliance instructions).shape_description(), policies can actively rewrite tool description properties to guide the LLM's action selection dynamically (e.g., adding warning prefixes).prioritize_skills(), the engine reorders available tools inside the formatted prompt XML, ensuring context-relevant or preferred skills are bubbled to the top of the LLM's consideration set.Testing Plan
1. Unit & Integration Tests (Command & Logs)
Added a complete integration test suite in
tests/plugins/test_taxonomy_plugin.pyto match the community plugin testing conventions (e.g., alongside the existingtest_agent_governance_plugin.py).To run the tests, set the
PYTHONPATHto include the community source files and your standard core SDK source directory:Verifiable Test Execution Log Output:
Note
Environmental Package Mock Details:
Due to potential environment variations where the
google-genailibrary is either outdated (lacking the expectedAvatarConfigattribute) or completely absent, we pre-emptively mock/patchgoogle.genai.types.AvatarConfigdirectly insidetests/conftest.py. This ensures that the test runner bypasses environment-level import conflicts and allows the unit test suite to compile cleanly in any CI/CD or local environment.2. Manual Verification E2E
To manually verify the taxonomy filter pipeline:
DefaultSkillPolicy:taxonomy-bindsto your skill's frontmatter configuration:list_skillswith a dynamic context (e.g. passing a user identity or role insidetool_context) and observe that skills bound to unauthorized taxonomies are securely filtered out of the response.Checklist
autoformat.sh/ standard formatting).Additional context
dictexpected by__build_response_event.