fix: read top-level api_server config fields into extra#20528
Open
Kailigithub wants to merge 2 commits into
Open
fix: read top-level api_server config fields into extra#20528Kailigithub wants to merge 2 commits into
Kailigithub wants to merge 2 commits into
Conversation
Add input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, reasoning_tokens, prompt_tokens, api_call_count, estimated_cost_usd, and cost_status to the JSON entry written by _save_session_log(). These counters are already tracked in-memory and persisted to SQLite, so including them in the session JSON gives users a complete picture without requiring a database lookup.
PlatformConfig.from_dict() now migrates top-level api_server fields (port, host, key, cors_origins) into the extra dict. This fixes a silent failure where ✓ Set platforms.api_server.port = 8643 in /root/.hermes/config.yaml would write the value at the top level of the api_server config block, but from_dict() only consumed fields inside extra — causing the gateway to ignore the port and fall back to the default with no warning.
Collaborator
Closed
19 tasks
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
PlatformConfig.from_dict()ingateway/config.pyonly consumed fields nested inside theextradict. When users set api_server values viahermes config set platforms.api_server.port 8643, the value is written at the top level of the api_server config block and never read — causing the gateway to silently fall back to the default port with no warning.Root Cause
from_dict()passeddata.get("extra", {})directly without checking for top-level fields thatApiServerPlatform.__init__also reads fromextra:porthostkeycors_originsFix
Before building
PlatformConfig, extract any of these top-level fields and merge them into theextradict. Fields already present inextratake precedence, preserving existing behaviour for users who wrote the correct structure.Testing
python3 -m py_compile gateway/config.py— passespytest tests/gateway/test_api_server.py— 15 passed (3 pre-existing async infra failures unrelated to this change; confirmed by running same tests on unmodified main)Closes #20501