Skip to content

fix: read top-level api_server config fields into extra#20528

Open
Kailigithub wants to merge 2 commits into
NousResearch:mainfrom
Kailigithub:fix/api-server-config-top-level-fields
Open

fix: read top-level api_server config fields into extra#20528
Kailigithub wants to merge 2 commits into
NousResearch:mainfrom
Kailigithub:fix/api-server-config-top-level-fields

Conversation

@Kailigithub

Copy link
Copy Markdown
Contributor

Summary

PlatformConfig.from_dict() in gateway/config.py only consumed fields nested inside the extra dict. When users set api_server values via hermes 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() passed data.get("extra", {}) directly without checking for top-level fields that ApiServerPlatform.__init__ also reads from extra:

  • port
  • host
  • key
  • cors_origins

Fix

Before building PlatformConfig, extract any of these top-level fields and merge them into the extra dict. Fields already present in extra take precedence, preserving existing behaviour for users who wrote the correct structure.

Testing

  • python3 -m py_compile gateway/config.py — passes
  • pytest 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

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.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles duplicate This issue or pull request already exists labels May 6, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #20506 — both fix PlatformConfig.from_dict() dropping top-level api_server keys (port, host, key) instead of merging into extra dict. Both close #20501.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

platforms.api_server config values (port, host, key) silently ignored when not nested under 'extra'

2 participants