Skip to content

fix(gateway): key-presence precedence for quick_commands nested fallback - #67992

Open
sergioperezcheco wants to merge 2 commits into
NousResearch:mainfrom
sergioperezcheco:fix/gateway-quick-commands-key-presence-precedence
Open

fix(gateway): key-presence precedence for quick_commands nested fallback#67992
sergioperezcheco wants to merge 2 commits into
NousResearch:mainfrom
sergioperezcheco:fix/gateway-quick-commands-key-presence-precedence

Conversation

@sergioperezcheco

Copy link
Copy Markdown
Contributor

Follow-up to 7354374. That commit established a key-presence precedence contract for load_gateway_config(): a present (even empty/falsy) top-level value must NOT be silently replaced by the nested gateway.* form, and it fixed session_reset and stt to use "key" not in yaml_cfg gating instead of truthiness checks. quick_commands was left on the old qc is None gate, so it's the one remaining sibling that doesn't honor that contract.

Concretely, quick_commands: null at the top level alongside a populated gateway.quick_commands block causes the nested value to leak through, because yaml_cfg.get("quick_commands") returns None for both "absent" and "present-null". The fix switches the gate to "quick_commands" not in yaml_cfg, matching session_reset/stt exactly. The legitimate nested-only path (top-level key genuinely absent) still falls back normally.

I added two regression tests mirroring the session_reset/stt ones: one asserting a present-null top-level blocks the nested fallback, and one sanity check that the nested fallback still fires when the top-level key is absent. I verified the first test fails on the pre-fix code and passes after, and the full tests/gateway/test_config.py suite (132 tests) stays green.

Follow-up for 7354374: the quick_commands nested-fallback used a
truthiness check (`qc is None`), so a present-but-empty top-level
quick_commands (e.g. `quick_commands: null`) was silently replaced by
gateway.quick_commands — inconsistent with the key-presence precedence
session_reset and stt now use, where the fallback fires only when the
top-level key is genuinely absent (not merely falsy/null).

This is the exact bug class the salvaged PR NousResearch#59779 follow-up fixed for
its two siblings; quick_commands was left on the old `is None` gate.
Switch to `"quick_commands" not in yaml_cfg` so a present top-level
value is honored even when empty, and add precedence + nested-fallback
regression tests mirroring the session_reset/stt ones.

Signed-off-by: sergioperezcheco <checo520@outlook.com>
@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 sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 20, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #67982 merged the neighboring nested-config bridge, while this live, focused patch retains a demonstrated quick_commands present-null precedence residual.

@sergioperezcheco

Copy link
Copy Markdown
Contributor Author

To clarify against the triage note: #67982 merged the neighboring nested-config bridge, but this PR fixes a separate `quick_commands` present-null precedence edge case that #67982 does not cover. The residual bug (nested key missing → fallback ignored) still reproduces on current main. Happy to add a regression test if that would help confirm the distinct scope.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused regression fix. The quick_commands premise is confirmed on current main: gateway/config.py:1312-1317 uses qc is None, so a present quick_commands: null is replaced by the nested value despite the adjacent documented key-presence contract at gateway/config.py:1302-1305.

Problems

  • The same contract is still not applied to profile_routes (gateway/config.py:1356-1360) or streaming (gateway/config.py:1376-1382): present null or mistyped top-level values can still fall back to gateway.*.

Suggested changes

  • Please apply the presence-based gate and focused regressions to those sibling paths as well, or explicitly document why their different behavior is intentional.

This is an automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 30, 2026
…reaming

Apply the same presence-based gate quick_commands now uses to
profile_routes and streaming: a present-but-null/mistyped top-level key
must not be silently replaced by the nested gateway.* form. The nested
fallback fires only when the top-level key is genuinely absent.

Adds precedence + fallback regression tests mirroring the existing
quick_commands/session_reset/stt ones.

Signed-off-by: sergioperezcheco <checo520@outlook.com>
@sergioperezcheco

Copy link
Copy Markdown
Contributor Author

Applied the presence-based gate to the sibling paths: profile_routes and streaming now use "key" not in yaml_cfg instead of the truthiness check, so a present-but-null or mistyped top-level value is honored (stays empty/default) instead of falling back to gateway.*. Added precedence + fallback regression tests for both, mirroring the quick_commands ones — 136 tests pass locally.

@alt-glitch alt-glitch added P3 Low — cosmetic, nice to have and removed P2 Medium — degraded but workaround exists labels Aug 12, 2026
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 P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants