a2ui-project/a2ui

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

Open

#1451 aperta il 18 mag 2026

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)TypeScript (1186 fork)github user discovery
P2component: samplesgood first issuestatus: needs reviewtype: bug

Metriche repository

Star
 (15.202 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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()

Guida contributor