|
16 | 16 |
|
17 | 17 | from __future__ import annotations |
18 | 18 |
|
19 | | -from abc import ABC |
20 | | -from abc import abstractmethod |
| 19 | +from abc import ABC, abstractmethod |
| 20 | +import logging |
| 21 | +from typing import Any, Optional |
21 | 22 |
|
22 | 23 | from google.adk.agents.readonly_context import ReadonlyContext |
23 | 24 | from google.adk.models.llm_request import LlmRequest |
24 | 25 | from google.adk.skills.models import Skill |
25 | 26 |
|
| 27 | +logger = logging.getLogger("google_adk_community." + __name__) |
26 | 28 |
|
27 | 29 | class TaxonomyResolver(ABC): |
28 | 30 | """Abstract base class for taxonomy resolution. |
@@ -190,6 +192,31 @@ def prioritize_skills( |
190 | 192 | """ |
191 | 193 | return skills |
192 | 194 |
|
| 195 | + def shape_skill( |
| 196 | + self, |
| 197 | + skill: Skill, |
| 198 | + context: ReadonlyContext, |
| 199 | + shaped_description: Optional[str], |
| 200 | + ) -> Skill: |
| 201 | + """Prepares and shapes a skill representation for presentation to the agent. |
| 202 | +
|
| 203 | + Defaults to a secure manual reconstruction to prevent accidental leakage of |
| 204 | + internal developer/business flags to LLM prompts, but can be overridden by |
| 205 | + custom policies to use `model_copy()` or other strategies. |
| 206 | + """ |
| 207 | + assert skill is not None, "Skill instance cannot be None" |
| 208 | + |
| 209 | + from google.adk.skills.models import Skill, Frontmatter |
| 210 | + extra = getattr(skill.frontmatter, "model_extra", None) or {} |
| 211 | + return Skill( |
| 212 | + frontmatter=Frontmatter( |
| 213 | + name=skill.frontmatter.name, |
| 214 | + description=shaped_description, |
| 215 | + **extra |
| 216 | + ), |
| 217 | + instructions=skill.instructions |
| 218 | + ) |
| 219 | + |
193 | 220 |
|
194 | 221 | def _get_taxonomy_binds(skill: Skill) -> list[str]: |
195 | 222 | """Dynamically extracts taxonomy binds, supporting both modified and unmodified core SDKs. |
@@ -228,6 +255,8 @@ def replace(match): |
228 | 255 | variables = (term.model_extra or {}).get("variables", {}) |
229 | 256 | if variables and var_name in variables: |
230 | 257 | return str(variables[var_name]) |
| 258 | + |
| 259 | + logger.warning("Taxonomy variable %r not found under active taxonomies: %s", var_name, active_taxonomies) |
231 | 260 | return "" |
232 | 261 |
|
233 | 262 | return re.sub(pattern, replace, text) |
|
0 commit comments