Skip to content

Fix: Handle None request_overrides in gateway/run.py - #7281

Closed
matt-legrand wants to merge 1 commit into
NousResearch:mainfrom
matt-legrand:fix/request-overrides-none
Closed

Fix: Handle None request_overrides in gateway/run.py#7281
matt-legrand wants to merge 1 commit into
NousResearch:mainfrom
matt-legrand:fix/request-overrides-none

Conversation

@matt-legrand

Copy link
Copy Markdown

Summary

Fixes AttributeError: 'NoneType' object has no attribute 'get' when request_overrides is None in gateway/run.py.

Root Cause

When service_tier is empty/falsy, _resolve_turn_route() sets route['request_overrides'] = None. This None is then directly assigned to agent.request_overrides at line 6974, bypassing the safe dict() initialization in run_agent.py line 678.

Later, _build_api_kwargs() at line 5522 calls self.request_overrides.get('speed') which crashes on None.

Fix

# gateway/run.py line 6974
agent.request_overrides = turn_route.get("request_overrides") or {}

This ensures request_overrides is always a dict, matching the constructor's safe initialization.

Testing

  • Verified fix resolves the AttributeError on local Hermes instance
  • No other changes to behavior when request_overrides is properly populated

Credits

Issue identified by @li3500764 in issue #7259.

When service_tier is empty/falsy, turn_route.get('request_overrides') returns None.
This None bypasses the safe dict() initialization in run_agent.py constructor,
causing AttributeError when _build_api_kwargs() calls .get() on None.

Fix: use 'or {}' fallback to ensure request_overrides is always a dict.

Fixes: NousResearch#7259
@matt-legrand
matt-legrand force-pushed the fix/request-overrides-none branch from 7cd7732 to 2b63c25 Compare April 10, 2026 16:54
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #7350 (merged) — same NoneType request_overrides fix. The referenced issue #7259 is already closed.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused fix. This is an automated hermes-sweeper review; the requested None-safety is already implemented on current main.

  • Merged PR fix: handle NoneType request_overrides in fast_mode check #7350 (0bea603510494629bdbd7c2c3397158fb33e5b91) added the direct API-helper guard; current code retains it at agent/chat_completion_helpers.py:688.
  • Gateway routing now emits {} rather than None when fast mode is disabled or unsupported (gateway/run.py:3921, gateway/run.py:3928).
  • The cached-agent update also applies the same normalization proposed here at gateway/run.py:18273.
  • Regression coverage explicitly verifies request_overrides = None does not crash at tests/run_agent/test_provider_parity.py:394-400.

The member note identifying #7350 as the duplicate is confirmed.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants