Skip to content

fix(gateway): merge instead of overwrite agent.request_overrides - #52432

Open
gitabtion wants to merge 1 commit into
NousResearch:mainfrom
gitabtion:fix/gateway-request-overrides-merge
Open

fix(gateway): merge instead of overwrite agent.request_overrides#52432
gitabtion wants to merge 1 commit into
NousResearch:mainfrom
gitabtion:fix/gateway-request-overrides-merge

Conversation

@gitabtion

@gitabtion gitabtion commented Jun 25, 2026

Copy link
Copy Markdown

Problem

After init_agent() merges custom_providers extra_body into
agent.request_overrides, the gateway runner's per-turn setup on
line 15856 unconditionally overwrites it:

agent.request_overrides = turn_route.get(request_overrides) or {}

turn_route.get(request_overrides) is {} when no
service_tier is set (see _make_turn_route at line 3487), so
any custom_providers extra_body that was injected during
agent init is silently discarded.

Fix

Merge instead of overwrite: preserve whatever the agent already
has in request_overrides, and only layer on turn_route
overrides when they are non-empty.

Tested

  • Confirmed custom_providers extra_body (e.g.
    content_filter: false for 360 provider) survives past the gateway
    per-turn setup when service_tier is not set.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jun 25, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating a real gateway reset bug. Current main merges matching custom-provider extra_body during initialization (agent/agent_init.py:1696), then discards it in the per-turn refresh (gateway/run.py:18394); the proposed copy-and-update directly addresses that sequence.

Problems

  • There is no regression test for the gateway sequence being changed. tests/agent/test_custom_provider_extra_body.py:6 tests the init helper, while tests/gateway/test_fast_command.py:107 tests route construction, but neither reaches the post-init assignment at gateway/run.py:18394.
  • This is only the reset sub-case. Current runtime and turn-route field whitelists still omit request_overrides at gateway/run.py:1895-1904 and gateway/run.py:3901-3910. The linked #53765 correctly identifies those as separate paths.

Suggested changes

  • Add a focused gateway regression that verifies custom-provider extra_body survives the per-turn refresh, including coexistence with a service-tier override.
  • Keep the PR explicitly narrow, or consolidate with the broader plumbing work; the one-line change should not be treated as covering model-switch or other runtime-resolution paths.

Automated hermes-sweeper review.

Comment thread gateway/run.py Outdated
@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Preserve initialization-time request overrides while replacing the previous turn's routing overrides during the gateway refresh. This keeps custom-provider extra_body settings without leaving stale fast-mode service_tier or speed values on cached agents.

Add a gateway regression covering coexistence with fast mode and the following normal turn.
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 P2 Medium — degraded but workaround exists 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 sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants