format_skills_as_xml escapes quotes in skill description, corrupting the prompt text

Đang mở
#8,199 1 bình luận 1 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

@llalitkumarrr đang làm issue này rồi.

Từ ngày 17/11/2026.

  • #8202 của @mattiolato98 — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

skills

🔴 Required Information

Describe the Bug:
google.adk.skills.prompt.format_skills_as_xml calls html.escape() with its default quote=True. Every " and ' in a skill's description is therefore turned into &quot; / &#x27; before the text goes into the system prompt. The skills block is plain text for an LLM, not an XML attribute value, so only <, > and & need escaping to keep the structure valid. Escaping quotes makes the description harder for the model to read and changes what the skill author wrote.

Steps to Reproduce:

  1. Run the following:
    from google.adk.skills import models, prompt
    
    skills = [
        models.Frontmatter(
            name="my-skill",
            description='never break the user\'s spaghetti, "al dente" is the law',
        )
    ]
    print(prompt.format_skills_as_xml(skills))
    
  2. Look at the <description> block in the output.

Expected Behavior:
The description is rendered as written:

<description>
never break the user's spaghetti, "al dente" is the law
</description>

Observed Behavior:
Quotes are HTML-escaped:

<description>
never break the user&#x27;s spaghetti, &quot;al dente&quot; is the law
</description>

Environment Details:

  • ADK Library Version (pip show google-adk): main (2.14.1) @ e1deb17f5
  • Desktop OS: Linux
  • Python Version (python -V): 3.11.18

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: N/A (the bug is in prompt construction, before any model call)

🟡 Optional Information

Regression:
Not checked. The html.escape(...) calls in src/google/adk/skills/prompt.py look like they were added with the escaping of </>/&, and the default quote=True was probably not intended.

Logs:
N/A

Screenshots / Video:
N/A

Additional Context:
The fix is to pass quote=False to both html.escape calls in format_skills_as_xml (name and description). <, > and & are still escaped, so the XML structure stays protected. The existing test desc&lt;ription&gt; still passes. A regression test, test_format_skills_as_xml_preserves_description_quotes, is added in tests/unittests/skills/test_prompt.py.

The fix is also applied to the name attribute, even if its field validator currently doesn't allow such values.

Minimal Reproduction Code:

from google.adk.skills import models, prompt

description = 'never break the user\'s spaghetti, "al dente" is the law'
xml = prompt.format_skills_as_xml(
    [models.Frontmatter(name="my-skill", description=description)]
)
assert description in xml  # fails: quotes are rendered as &quot; / &#x27;

How often has this issue occurred?:

  • Always (100%)

Ngôn ngữ chính
Python
Star
22.3k
Fork
4.4k
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của google/adk-python

Tất cả issue của google/adk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.