Skip to content

fix(skill_toolset): enforce utf-8 encoding when materializing skill files on Windows#5820

Open
mc-marcocheng wants to merge 1 commit into
google:mainfrom
mc-marcocheng:fix/skill-toolset-utf8
Open

fix(skill_toolset): enforce utf-8 encoding when materializing skill files on Windows#5820
mc-marcocheng wants to merge 1 commit into
google:mainfrom
mc-marcocheng:fix/skill-toolset-utf8

Conversation

@mc-marcocheng
Copy link
Copy Markdown

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem:
When running the ADK on Windows, executing a skill script via _SkillScriptCodeExecutor fails with a UnicodeEncodeError if the skill's resources (references, assets, or scripts) contain non-ASCII characters. The generated wrapper script writes these files without specifying an encoding, causing Windows to fall back to its system locale encoding (e.g., cp1252).

Solution:
By explicitly setting encoding='utf-8' when mode == 'w' in the generated wrapper script, we ensure that text files are correctly written regardless of the system's default locale encoding. Binary assets (mode == 'wb') continue to be handled properly without an encoding argument.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary of passed pytest results:

tests\unittests\tools\test_skill_toolset.py ................................................................ [ 67%]
...............................                                                                              [100%]
========================================= 95 passed, 6 warnings in 15.68s =========================================

Manual End-to-End (E2E) Tests:

  • Reproduced the issue manually on Windows using a custom Python script that invokes _build_wrapper_code with Chinese characters (你好,世界) and executed the generated script.
  • Verified that applying the fix resolves the UnicodeEncodeError during manual execution.
  • Wrote an integration test (test_integration_python_unicode_materialization) that acts as an automated E2E test by using the real UnsafeLocalCodeExecutor to materialize and run a script reading the Unicode content.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

N/A

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 23, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label May 23, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented May 23, 2026

Response from ADK Triaging Agent

Hello @mc-marcocheng, thank you for creating this PR!

It looks like the Google Contributor License Agreement (CLA) check has failed for this pull request. Could you please complete the following action from our contribution guidelines?

  • Before you begin: Sign our Contributor License Agreement

You can visit https://cla.developers.google.com/ to see your current agreements or to sign a new one. This is required so that we can review and merge your contribution.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: UnicodeEncodeError on Windows when materializing skill resources in _SkillScriptCodeExecutor

2 participants