Skip to content

fix(gateway): stop model overrides failing in multi-agent gateways - #137913

Merged
obviyus merged 1 commit into
mainfrom
codex/issue-137820
Sep 4, 2026
Merged

obviyus merged 1 commit into
mainfrom
codex/issue-137820

Conversation

@obviyus

@obviyus obviyus commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #137820. Thanks @syncword for the report.

What Problem This Solves

Selecting an agent and overriding its model could return HTTP 500 in a multi-agent Gateway with no ambient owner. Both chat-completion and response endpoints were affected.

Why This Change Was Made

The shared override helper now passes the already-selected agent into the model catalog loader. The catalog can apply that agent's visibility policy without trying to select an ambient owner.

User Impact

Selected agents can use allowed overrides without a system agent. Disallowed overrides return the normal HTTP 400 rejection, and unknown-agent rejection stays unchanged. No configuration or model-policy change.

Evidence

Real Gateway requests reproduced HTTP 500 before the fix and correct HTTP 400 rejection afterward across both endpoints and two agents, including after restart. Four allowed live inference requests returned HTTP 200. The two new regression cases failed before the change; all 57 focused tests passed afterward.

Consumers: both HTTP model-override endpoints pass the selected agent to catalog lookup.

AI-assisted.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Sep 4, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 12:44 AM ET / 04:44 UTC.

ClawSweeper review

What this changes

The PR passes the selected HTTP agent into prepared model-catalog loading for model overrides and adds a two-agent regression check.

Merge readiness

✅ Ready for maintainer review

Keep open. This is a focused owner-boundary repair: current main drops the already-selected agent before catalog loading, while the patch preserves it for both OpenAI-compatible HTTP endpoints. No blocking correctness or security defect was found.

Priority: P1
Reviewed head: bd55985cec4cfadba41b2a03da62fa288f40a7bf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, coherent repair with direct owner-path coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the PR body also documents built-Gateway before/after HTTP probes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the PR body also documents built-Gateway before/after HTTP probes.
Evidence reviewed 6 items Current main remains affected: Fetched main still calls the catalog loader without the already-resolved agent ID, so it can fall back to ambient owner resolution.
Patch repairs the owner handoff: The introduced production change passes the same selected agent ID used by the visibility policy into catalog loading.
Catalog contract accepts selected owners: The Gateway catalog loader forwards an optional agent ID to the prepared catalog owner loader.
Findings None None.
Security None None.

How this fits together

Gateway Chat Completions and Responses requests resolve and authorize an agent before processing an optional model override. The override resolver loads that agent’s prepared model catalog, applies its visibility policy, and returns either the allowed model or an HTTP error.

flowchart LR
  A[HTTP client] --> B[Chat or Responses endpoint]
  B --> C[Selected agent]
  C --> D[Model override resolver]
  D --> E[Prepared model catalog]
  E --> F[Agent visibility policy]
  F --> G[Agent run or HTTP error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +2. Total +2 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 6 4 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 7 5 +2

Review metrics

Metric Value Why it matters
Production vs test delta production +1/-1, net 0; tests +6/-4, net +2 The owner-boundary fix is production-neutral and the added test coverage targets both configured agents.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137820
Summary: This PR is a focused candidate fix for the linked report and its stated multi-agent model-override failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land this single forwarding repair after ordinary exact-head CI gates so selected-agent model overrides use the selected agent’s prepared catalog.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main resolves an explicit HTTP agent but calls the prepared catalog without it; in an explicit multi-agent configuration that reaches ambient-owner resolution and its selection error. I did not execute the supplied live scenario in this read-only review.

Is this the best way to solve the issue?

Yes. Passing the already-resolved agent through the existing catalog-loader contract preserves one canonical path and avoids an incorrect global default or ambient-owner fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c6ea391c9298.

Labels

Label changes:

  • add P1: The repaired regression prevents existing multi-agent Gateway clients from completing model-override requests.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the PR body also documents built-Gateway before/after HTTP probes.

Label justifications:

  • P1: The repaired regression prevents existing multi-agent Gateway clients from completing model-override requests.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the PR body also documents built-Gateway before/after HTTP probes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@obviyus
obviyus merged commit 29b57be into main Sep 4, 2026
187 checks passed
@obviyus
obviyus deleted the codex/issue-137820 branch September 4, 2026 04:48
@obviyus

obviyus commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @syncword!

Proof: Real built Gateway with two explicitly owned agents, both HTTP routes, no ambient owner, and process-restart coverage. Four allowed-override requests reached the real provider and returned correct answers.

  • Bug: x-openclaw-model requests lost their explicitly selected agent while loading the model catalog, causing HTTP 500.
  • Fix: The shared HTTP helper now carries that agent into the existing catalog owner boundary.
Before After
Both routes failed with AgentSelectionRequiredError for either selected agent Both routes return the selected agent's HTTP 400 visibility rejection for a disallowed override
Restart repeated the failure Restart preserves correct behavior
Unknown agents returned HTTP 400 Unchanged

Validation: 57 focused tests pass; the two ownership regression cases fail on pre-fix production. Exact-head real HTTP proof and Autoreview are green. Production line count is unchanged.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…penclaw#137913)

Preserve the explicitly selected agent when validating model overrides for the chat completions and responses HTTP endpoints. Multi-agent gateways without an ambient owner now return the selected agent's visibility rejection instead of HTTP 500.

Proved both routes with two agents before and after process restart, unknown-agent controls, and four successful real-provider requests. All 57 focused tests pass; production line count is unchanged.

Fixes openclaw#137820. Thanks @syncword for reporting the regression.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AgentSelectionRequiredError when calling /v1/chat/completions from external HTTP client with multiple agents configured

1 participant