fix(tests): pass timezone_name to record_token_usage in settings tests - #5349
Open
albatrossflyon-coder wants to merge 3 commits into
Open
fix(tests): pass timezone_name to record_token_usage in settings tests#5349albatrossflyon-coder wants to merge 3 commits into
albatrossflyon-coder wants to merge 3 commits into
Conversation
test_settings_payload_includes_token_usage_summary and test_settings_usage_payload_returns_lightweight_token_usage called record_token_usage() with no timezone_name, defaulting to UTC, while settings_payload()/settings_usage_payload() always read back with config.agents.defaults.timezone (America/Chicago by default). Whenever UTC has already rolled to the next calendar day but the configured timezone hasn't (roughly a 5-hour daily window for US Central), the row lands under a date the windowed fields (requests_30d, active_days_30d, total_tokens_30d, current_streak_days) never look at, since they filter against "today" computed in the configured timezone. Every real production call site (gateway_runtime.py x2, command/builtin.py) already threads the configured timezone through consistently, so this is a test-only gap. Matches the convention tests/webui/test_token_usage.py already uses. Fixes HKUDS#5348.
albatrossflyon-coder
added a commit
to albatrossflyon-coder/nanobot
that referenced
this pull request
Aug 12, 2026
Collaborator
|
BUILDLOG.md |
BUILDLOG.md is an internal fork-tracking file (our own convention, not part of upstream's docs) that only shows up in this diff because it lives on our fork's main but not on HKUDS:main. It doesn't belong in a PR meant to land upstream. Removed here; still present on the fork's own main branch.
albatrossflyon-coder
added a commit
to albatrossflyon-coder/nanobot
that referenced
this pull request
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5348 — two tests in
tests/webui/test_settings_api.pyfail deterministically during a ~5-hour daily window becauserecord_token_usage()was called withouttimezone_name, defaulting to UTC, while the payload read-back (settings_payload()/settings_usage_payload()) always reads withconfig.agents.defaults.timezone(America/Chicagoby default). Whenever UTC has already rolled to the next calendar day but the configured timezone hasn't, the written row falls outside every windowed field'stodaycutoff.Full root-cause writeup, including confirmation this is test-only (all three real production call sites already thread the configured timezone correctly), is in #5348.
Fix
Pass
timezone_name=config.agents.defaults.timezoneto bothrecord_token_usage()calls, matching the conventiontests/webui/test_token_usage.pyalready uses everywhere else in this file's neighborhood.Test plan
test_settings_payload_includes_token_usage_summary,test_settings_usage_payload_returns_lightweight_token_usagetests/webui/test_settings_api.pyfile: 85 passed