The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(hosted-rooms): read the Discussion budgets through the effective loader, keep defaults on a typo
Teknium41010b6fefdc
diff --git a/cli-config.yaml.example b/cli-config.yaml.exampleindex d66a9db7ea9..4b8419b619a 100644--- a/cli-config.yaml.example+++ b/cli-config.yaml.example@@ -1052,7 +1052,8 @@ group_sessions_per_user: true# =============================================================================# Shared ceilings per discussion across all members, applied to all native hosted# rooms (not Desktop renderer/mirrored rooms). Positive integers only: no 0,-# unlimited, null, booleans, strings, or floats. Omitted keys keep these defaults.+# unlimited, null, booleans, strings, or floats; an invalid value is logged and+# the defaults apply. Omitted keys keep these defaults.# Set in the root owner's config.yaml beside shared-state.db, not a member's# profile config. Read once at startup; refresh every server process sharing the# room database to apply (not just the service the client connects to).diff --git a/tests/tui_gateway/test_hosted_room_discussion_limits.py b/tests/tui_gateway/test_hosted_room_discussion_limits.pyindex 7827cfa87ee..b5893074702 100644--- a/tests/tui_gateway/test_hosted_room_discussion_limits.py+++ b/tests/tui_gateway/test_hosted_room_discussion_limits.py@@ -174,15 +174,22 @@ def test_owner_settings_do_not_leak_from_a_member_scope_and_defaults_are_unchang@pytest.mark.parametrize("key", ["max_rounds", "max_messages"])@pytest.mark.parametrize("value", ["0", "-1", "true", "1.5", "'6'", "null", "[]", "{}"])-def test_invalid_limits_are_rejected_before_any_room_work(tmp_path, key, value):+def test_an_invalid_limit_keeps_the_defaults_and_names_the_key(tmp_path, caplog, key, value):+ """A typo in one budget must not take every room on the store offline."""(tmp_path / "config.yaml").write_text(f"hosted_rooms:\n discussion:\n {key}: {value}\n")with pytest.raises(discussion.DiscussionValidationError, match=f"{key} must be a positive integer"):- _service(tmp_path)- assert not (tmp_path / "state.db").exists()+ discussion.DiscussionLimits(**{key: yaml_value(value)})+ service = _service(tmp_path)+ assert service.discussion_limits == discussion.DiscussionLimits()+ assert f"hosted_rooms.discussion.{key} must be a positive integer" in caplog.text@pytest.mark.parametrize("section", ["hosted_rooms: []", "hosted_rooms:\n discussion: []"])-def test_invalid_config_sections_fail_closed(tmp_path, section):+def test_an_invalid_config_section_keeps_the_defaults(tmp_path, caplog, section):(tmp_path / "config.yaml").write_text(section + "\n")- with pytest.raises(discussion.DiscussionValidationError, match="must be a mapping"):- _service(tmp_path)+ assert _service(tmp_path).discussion_limits == discussion.DiscussionLimits()+ assert "must be a mapping" in caplog.text+++def yaml_value(text):+ return {"0": 0, "-1": -1, "true": True, "1.5": 1.5, "'6'": "6", "null": None, "[]": [], "{}": {}}[text]diff --git a/tui_gateway/hosted_room_service.py b/tui_gateway/hosted_room_service.pyindex d6d3e59af18..55db3673931 100644--- a/tui_gateway/hosted_room_service.py+++ b/tui_gateway/hosted_room_service.py@@ -3,6 +3,7 @@from __future__ import annotationsimport contextlib+import loggingimport osimport threadingimport time@@ -35,6 +36,7 @@ _TERMINAL_STATUSES = ("deferred", "settled", "failed", "cancelled")_LIVE_STATUSES = ("queued", "running", "stopping")_STOPPABLE_STATUSES = ("queued", "running", "indeterminate", "deferred", "stopping")_RETRYABLE_STATUSES = ("indeterminate", "deferred")+logger = logging.getLogger(__name__)def task_member_id(task: Mapping[str, Any]) -> str:@@ -48,21 +50,26 @@ def attempt_action(kind: str, task: Mapping[str, Any]) -> dict[str, Any]:def _discussion_limits(root: Path) -> discussion.DiscussionLimits:- """Read the room owner's config, never the current member's profile scope."""+ """Read the room owner's config, never the current member's profile scope. A malformed value+ keeps today's defaults (logged) rather than taking every room on this store offline."""from gateway.run import _profile_runtime_scope- from hermes_cli.config import load_config+ from hermes_cli.config_effective import load_user_config_effectivewith _profile_runtime_scope(root, hydrate_secrets=False):- config = load_config()- rooms = config.get("hosted_rooms", {})- if not isinstance(rooms, Mapping):- raise discussion.DiscussionValidationError("hosted_rooms must be a mapping")- settings = rooms.get("discussion", {})- if not isinstance(settings, Mapping):- raise discussion.DiscussionValidationError("hosted_rooms.discussion must be a mapping")- return discussion.DiscussionLimits(- max_rounds=settings.get("max_rounds", discussion.MAX_DISCUSSION_ROUNDS),- max_messages=settings.get("max_messages", discussion.MAX_DISCUSSION_MESSAGES))+ config = load_user_config_effective()+ try:+ rooms = config.get("hosted_rooms", {})+ if not isinstance(rooms, Mapping):+ raise discussion.DiscussionValidationError("hosted_rooms must be a mapping")+ settings = rooms.get("discussion", {})+ if not isinstance(settings, Mapping):+ raise discussion.DiscussionValidationError("hosted_rooms.discussion must be a mapping")+ return discussion.DiscussionLimits(+ max_rounds=settings.get("max_rounds", discussion.MAX_DISCUSSION_ROUNDS),+ max_messages=settings.get("max_messages", discussion.MAX_DISCUSSION_MESSAGES))+ except discussion.DiscussionValidationError as exc:+ logger.warning("ignoring hosted_rooms.discussion in %s/config.yaml: %s", root, exc)+ return discussion.DiscussionLimits()def _hosted_room_turn_timeout_seconds() -> float:diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex 9ed2c3b304e..eaae3d8521c 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -2705,13 +2705,16 @@ hosted_rooms:Both keys are optional; omitted keys retain the backward-compatible defaults of3 rounds and 10 replies. Values must be positive integers: `0`, negative values,`null`, booleans, strings (including quoted numbers or `"unlimited"`), and floats-are not accepted. For example, set `max_rounds: 6` and `max_messages: 30` for a-larger, still bounded discussion budget.--Set these keys in the root owner's `config.yaml` alongside `shared-state.db`, not-in an individual room member's profile configuration. Each server process reads-them once at startup. Refresh every participating process sharing that room-database, not just the service the client connects to, after changing them.+are not accepted. An invalid value is ignored with a warning in the gateway log and+the defaults apply, so a typo never takes group chat offline. For example, set+`max_rounds: 6` and `max_messages: 30` for a larger, still bounded discussion budget+(a 5-member room then gets past the 10-reply stop).++Set these keys in the `config.yaml` of the Hermes home that holds the room store+(the root home beside `shared-state.db`), not in an individual room member's profile+configuration. They apply to rooms served by the gateway and by the Desktop/TUI+backend alike. Each server process reads them once at startup: restart every+process sharing that room store after changing them.These are ceilings, not targets or a guarantee of task completion. Discussionscan settle early, and Stop and approval gates remain in effect.