Skip to content

fix(gateway): preserve custom_providers extra_body on reused-agent turns - #68946

Open
IbrahimKhan12 wants to merge 1 commit into
NousResearch:mainfrom
IbrahimKhan12:fix/54922-gateway-extra-body-clobber
Open

fix(gateway): preserve custom_providers extra_body on reused-agent turns#68946
IbrahimKhan12 wants to merge 1 commit into
NousResearch:mainfrom
IbrahimKhan12:fix/54922-gateway-extra-body-clobber

Conversation

@IbrahimKhan12

@IbrahimKhan12 IbrahimKhan12 commented Jul 21, 2026

Copy link
Copy Markdown

Why

Gateway cached-agent turns replace request_overrides, dropping durable custom_providers[].extra_body values initialized on the agent. Custom-provider requests therefore behave differently between CLI and messaging paths, silently removing fields such as reasoning_effort.

What

Reapply matching custom-provider extra_body defaults after active-runtime restoration at the start of each agent turn. Explicit turn-level top-level and nested values retain precedence, and defaults are applied only to the active provider runtime so cooldown-active fallbacks do not inherit primary-provider settings.

Add regression coverage for a reused gateway agent across fast and normal turns, merge precedence, restored primary runtimes, and cooldown-active fallbacks.

Testing

  • scripts/run_tests.sh tests/agent/test_custom_provider_extra_body.py tests/agent/test_turn_context.py tests/gateway/test_fast_command.py -q
  • python -m ruff check agent/agent_init.py agent/turn_context.py tests/agent/test_custom_provider_extra_body.py tests/agent/test_turn_context.py tests/gateway/test_fast_command.py
  • git diff --check origin/main..HEAD

References

@IbrahimKhan12
IbrahimKhan12 marked this pull request as ready for review July 21, 2026 21:49
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles needs-decision Awaiting maintainer decision before any implementation sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related competing fixes for #54922: #30224 preserves existing overrides then clears known transient keys; #52432 tracks/removes the previous turn payload; this PR recomputes durable extra_body from config each turn. These are different state-management contracts, so maintainer selection is needed.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for isolating the durable-versus-transient override contract. The defect is still present on current main: gateway/run.py:22480 replaces the cached agent's init-time request_overrides, while agent/agent_init.py:2225-2226 establishes the config-derived custom-provider extra_body that must persist. The stateless recomputation in this PR matches the issue discussion's warning against accumulating /fast state.

Problems

  • The new tests cover the helper and ChatCompletionsTransport, but do not drive the actual cached-agent reuse assignment at gateway/run.py:22480. That leaves the load-bearing gateway wiring untested.

Suggested changes

  • Add a gateway-level reuse test covering custom-provider extra_body, a fast turn, and the following non-fast turn. Assert the durable body remains and the transient service tier does not leak.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state 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 30, 2026
@IbrahimKhan12

Copy link
Copy Markdown
Author

ack will fix

@IbrahimKhan12
IbrahimKhan12 force-pushed the fix/54922-gateway-extra-body-clobber branch 2 times, most recently from a8cbe45 to 0282316 Compare July 30, 2026 21:41
@alt-glitch alt-glitch removed the sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state label Jul 30, 2026
- Reapply custom-provider defaults after active runtime restoration.
- Keep explicit turn overrides authoritative without retaining prior turns.
@IbrahimKhan12
IbrahimKhan12 force-pushed the fix/54922-gateway-extra-body-clobber branch from 0282316 to a36d28e Compare July 30, 2026 22:19
@IbrahimKhan12

Copy link
Copy Markdown
Author

Done, revised the PR.

@alt-glitch alt-glitch removed sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 31, 2026
@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown

This was generated by AI during triage.

Summary

Two open PRs address #54922 through different state-management contracts: #30224 merges existing cached-agent overrides with each turn, while #68946 reconstructs durable custom-provider extra_body from configuration after runtime restoration and now exercises fast-to-normal cached-agent reuse.

Related pull requests

Duplicates

#30224 and #68946 are competing fixes for the same cached-agent overwrite behind #54922; #30224 can be treated as superseded by #68946.

Suggested consolidation

Keep #68946 open with a salvage path: retain its stateless configuration-derived reconstruction, active-runtime scoping, precedence handling, and newly added cached-agent fast-to-normal regression, then obtain review of the revision. Close #30224 as a duplicate of #68946; despite #30224's keep_open review, its diff leaves the review-identified runtime request_overrides routing omission unresolved and tests only its helper.

Complex graph

flowchart LR
    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
    classDef best stroke-width:3px,stroke:#b45309
    classDef target stroke-width:3px,stroke:#4338ca
    I54922(["issue #54922 (open)"])
    subgraph Dup30224 ["PRs duplicating each other"]
        P30224["PR #30224 (open)"]
        P68946["PR #68946 (open)"]
    end
    P68946 -->|best fix| I54922
    class I54922 open
    class P30224 open
    class P68946 open
    class P68946 best
    class P68946 target
    click I54922 "https://github.com/NousResearch/hermes-agent/issues/54922"
    click P30224 "https://github.com/NousResearch/hermes-agent/pull/30224"
    click P68946 "https://github.com/NousResearch/hermes-agent/pull/68946"
Loading

Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label).

Cross-PR triage: Reviewed 2 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 13 kB of PR diffs, 14 kB of issue/PR text, 5 kB of discussion (6 comments), 3 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: custom_providers[].extra_body silently dropped on gateway/messaging paths (CLI works)

4 participants