Description
Describe the bug
When I run my agent the program crashes with an fast_api.py error: Error in event_generator: 'charmap' codec can't decode byte 0x81 in position 1980: character maps to
To Reproduce
Steps to reproduce the behavior:
- run adk web
- Select the agent in the dropdown
- Send any message
- See error
Expected behavior
There should not be an error. I want the agents to respond properly.
Desktop (please complete the following information):
- OS: Windows 11, Germany
- Python: 3.13.3
- ADK: 0.3.0
Additional context
This is basically the starter example. I just changed the model to Anthropic.
init.py:
"""
from . import agent
"""
agent.py:
"""
import datetime
from zoneinfo import ZoneInfo
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
def get_weather(city: str) -> dict:
"""Retrieves the current weather report for a specified city.
Args:
city (str): The name of the city for which to retrieve the weather report.
Returns:
dict: status and result or error msg.
"""
if city.lower() == "new york":
return {
"status": "success",
"report": (
"The weather in New York is sunny with a temperature of 25 degrees"
" Celsius (77 degrees Fahrenheit)."
),
}
return {
"status": "error",
"error_message": f"Weather information for {city} is not available.",
}
def get_current_time(city: str) -> dict:
"""Returns the current time in a specified city.
Args:
city (str): The name of the city for which to retrieve the current time.
Returns:
dict: status and result or error msg.
"""
if city.lower() == "new york":
tz_identifier = "America/New_York"
else:
return {
"status": "error",
"error_message": (
f"Sorry, I dont have timezone information for {city}."
),
}
tz = ZoneInfo(tz_identifier)
now = datetime.datetime.now(tz)
report = (
f"The current time in {city} is {now.strftime("%Y-%m-%d %H:%M:%S %Z%z")}"
)
return {"status": "success", "report": report}
root_agent = LlmAgent(
name="weather_time_agent",
model=LiteLlm(model="anthropic/claude-3-5-haiku-20241022"),
description=(
"Agent to answer questions about the time and weather in a city."
),
instruction=(
"You are a helpful agent who can answer user questions about the time"
" and weather in a city."
),
tools=[get_weather, get_current_time],
)
"""
.env:
"""
ANTHROPIC_API_KEY=sk-ant-a....wAD
"""
The full error stack:
2025-04-25 21:56:48,237 - ERROR - fast_api.py:637 - Error in event_generator: 'charmap' codec can't decode byte 0x81 in position 1980: character maps to
Traceback (most recent call last):
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\google\adk\cli\fast_api.py", line 625, in event_generator
runner = await _get_runner_async(req.app_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\google\adk\cli\fast_api.py", line 796, in _get_runner_async
root_agent = await _get_root_agent_async(app_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\google\adk\cli\fast_api.py", line 773, in get_root_agent_async
agent_module = importlib.import_module(app_name)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python313\Lib\importlib_init.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in find_and_load_unlocked
File "", line 935, in load_unlocked
File "", line 1026, in exec_module
File "", line 488, in call_with_frames_removed
File "E:\Projekte\agent_quickstart_init.py", line 7, in
from . import agent
File "E:\Projekte\agent_quickstart\agent.py", line 11, in
from google.adk.models.lite_llm import LiteLlm
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\google\adk\models\lite_llm.py", line 31, in
from litellm import acompletion
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\litellm_init.py", line 762, in
from .cost_calculator import completion_cost
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\litellm\cost_calculator.py", line 19, in
from litellm.litellm_core_utils.llm_cost_calc.utils import (
...<2 lines>...
)
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\litellm\litellm_core_utils\llm_cost_calc\utils.py", line 9, in
from litellm.utils import get_model_info
File "E:\Projekte\agent_quickstart\venv\Lib\site-packages\litellm\utils.py", line 188, in
json_data = json.load(f)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python313\Lib\json_init.py", line 293, in load
return loads(fp.read(),
~~~~~~~^^
File "C:\Users\myuser\AppData\Local\Programs\Python\Python313\Lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1980: character maps to