a2ui-project/a2ui

UnicodeDecodeError on Windows when running restaurant_finder sample due to default GBK encoding

Open

#1,451 opened on May 18, 2026

View on GitHub
 (1 comment) (0 reactions) (0 assignees)TypeScript (1,186 forks)github user discovery
P2component: samplesgood first issuestatus: needs reviewtype: bug

Repository metrics

Stars
 (15,202 stars)
PR merge metrics
 (PR metrics pending)

Description

Description

When running the restaurant_finder sample on Windows, the agent fails when reading the restaurant data file.

The issue appears to be caused by Python using the system default encoding on Windows. On a Chinese Windows environment, the default encoding is gbk, but the data file seems to be encoded as UTF-8.

As a result, the sample crashes with a UnicodeDecodeError.

Environment

  • OS: Windows
  • Shell: PowerShell
  • Project path: samples/agent/adk/restaurant_finder
  • Python environment: created by uv
  • Sample: A2UI restaurant finder demo

Steps to Reproduce

  1. Start the restaurant finder agent:
cd samples/agent/adk/restaurant_finder
uv run .
  1. Start the Lit client shell:
cd samples/client/lit/shell
npm run dev
  1. Open the demo in the browser and send a restaurant-related prompt.

Actual Behavior实际行为

The agent crashes with the following error:

UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 198: illegal multibyte sequence

Full relevant traceback:

File "samples/agent/adk/restaurant_finder/tools.py", line 40, in get_restaurants
    restaurant_data_str = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 198: illegal multibyte sequence

Possible Cause

In samples/agent/adk/restaurant_finder/tools.py, the file is opened without specifying an encoding:

with open(...) as f:
    restaurant_data_str = f.read()

Suggested Fix

Specify UTF-8 explicitly when reading the data file:

with open(..., "r", encoding="utf-8") as f:
    restaurant_data_str = f.read()

Contributor guide