set timezone
I have a ridiculous amount of this in my logs:
Debug: Changing timezone from America/Winnipeg to America/Chicago
Debug: Changing timezone from America/Chicago to America/Winnipeg
And when I say ridiculous:
grep -v -P 'Debug: Changing timezone from' *.html|wc -l
320
grep -P 'Debug: Changing timezone from' *.html|wc -l
69501
~99.5% of my logs
Can I just set it so it doesn't fluctuate like that?
I take it
Hello, I've been experiencing the same issue with log spam due to fluctuating timezones and have a solution that resolves it.
The root cause is, as suspected, that the poll.py API endpoint is using the timezone sent by the client with each request. This causes the server's timezone context to change constantly when accessed from multiple devices, leading to the excessive log messages.
The fix is to force the server to use a single, stable timezone defined in the .env file (DEFAULT_USER_TIMEZONE), ignoring what the client sends. This ensures all logs are timestamped consistently.
Here are the complete changes required to fix the issue in /python/api/poll.py:
--- a/python/api/poll.py +++ b/python/api/poll.py @@ -1,4 +1,4 @@ -from python.helpers.api import ApiHandler, Request, Response +import time +from datetime import datetime +from python.helpers.api import ApiHandler +from flask import Request, Response
from agent import AgentContext
@@ -14,11 +14,12 @@
async def process(self, input: dict, request: Request) -> dict | Response:
-
ctxid = input.get("context", "")
-
ctxid = input.get("context", None) from_no = input.get("log_from", 0) # Get timezone from input (default to dotenv default or UTC if not provided)
-
timezone = input.get("timezone", get_dotenv_value("DEFAULT_USER_TIMEZONE", "UTC"))
-
# timezone = input.get("timezone", get_dotenv_value("DEFAULT_USER_TIMEZONE", "UTC")) -
timezone = get_dotenv_value("DEFAULT_USER_TIMEZONE", "UTC") Localization.get().set_timezone(timezone) # context instance - get or create
This change completely resolves the log spam and stabilizes the timezone handling. Hope this helps!
I added rate limiter to the localization class here: https://github.com/agent0ai/agent-zero/pull/664.
The above code suggested sadly just pins the timezone to UTC no matter what users timezone is - that's not really desired.