fix(gateway): persist trailing @profile suffix as session auth profile override on model patch#87123
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 26, 2026, 10:47 PM ET / 02:47 UTC. Summary PR surface: Source +3, Tests +51, Docs +2. Total +56 across 3 files. Reproducibility: yes. source inspection gives a high-confidence path: docs require Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance: Risk before merge
Maintainer options:
Next step before merge Security Review findings
Review detailsBest possible solution: Land the focused sessions.patch persistence fix after the contributor adds real behavior proof and removes the release-owned changelog entry. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence path: docs require Is this the best way to solve the issue? Yes, the code fix is the narrow existing-seam solution: reuse Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 9119492f158a. Label changesLabel justifications:
Evidence reviewedPR surface: Source +3, Tests +51, Docs +2. Total +56 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
0928610 to
02529bf
Compare
|
Verification for updated head 02529bf: Behavior addressed: Real environment tested: local macOS checkout, Node/Vitest repo wrapper; GitHub Actions PR CI on openclaw/openclaw. Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: session patch tests cover provider-qualified profile refs, same-model profile-only live switch pending state, full provider:profile IDs, no-suffix behavior, and bare allowlisted model IDs with profile suffixes. What was not tested: live Pi/Codex OAuth turn with real credentials; the changed persistence and live-switch decision paths are covered by focused local tests and full PR CI. |
Summary
/model openai/gpt-5.5@openai-codex:[email protected]was documented as a way to pin a session auth profile, but thesessions.patchhandler insrc/gateway/sessions-patch.tsstripped the@profilesuffix during model resolution and never passed it toapplyModelOverrideToSessionEntry. The user got the misleading errorAuth profile "openai-codex:[email protected]" is for openai-codex, not openai.because the profile was never persisted to the session entry.This change extracts the trailing
@profilesuffix via the existingsplitTrailingAuthProfilehelper and passes it asprofileOverridetoapplyModelOverrideToSessionEntry, matching the documented contract indocs/gateway/authentication.md.Closes #87099.
Change Type
Scope
Linked Issue
Real behavior proof
Behavior or issue addressed:
/model <ref>@<profile>pinning strips the auth profile suffix on the session patch path, so the documented credential pin never reaches the session entry and the user receives a misleading provider-routing error.Real environment tested: macOS 26.5 arm64, Node v22.22.0, upstream main @ 8fa5ecb
Exact steps or command run after this patch:
Run the full sessions-patch test suite across all three gateway environments:
Drift proof — revert the src patch and confirm the three new
@profiletests fail:Restore and confirm all pass:
Lint and format:
Typecheck:
Evidence after fix:
// Step 1: All 144 tests pass (48 tests × 3 environments)
$ node scripts/run-vitest.mjs run src/gateway/sessions-patch.test.ts
RUN v4.1.7 /Users/xin/.openclaw/workspace/openclaw
✓ gateway-core ../../src/gateway/sessions-patch.test.ts (48 tests) 963ms
✓ gateway-server ../../src/gateway/sessions-patch.test.ts (48 tests) 911ms
✓ gateway-client ../../src/gateway/sessions-patch.test.ts (48 tests) 901ms
Test Files 3 passed (3)
Tests 144 passed (144)
// Step 2: Drift proof — revert src, tests fail on missing authProfileOverride
$ git stash push -- src/gateway/sessions-patch.ts
$ node scripts/run-vitest.mjs run src/gateway/sessions-patch.test.ts
❯ gateway-core ../../src/gateway/sessions-patch.test.ts (48 tests | 3 failed)
❯ gateway-server ../../src/gateway/sessions-patch.test.ts (48 tests | 3 failed)
❯ gateway-client ../../src/gateway/sessions-patch.test.ts (48 tests | 3 failed)
// All 6 failures are for authProfileOverride being undefined (expected without the patch)
// Step 3: Restore and re-run — back to 144 pass
$ git stash pop
$ node scripts/run-vitest.mjs run src/gateway/sessions-patch.test.ts
Test Files 3 passed (3)
Tests 144 passed (144)
// Step 4-5: Format + lint + typecheck all clean
$ npx oxfmt --check src/gateway/sessions-patch.ts src/gateway/sessions-patch.test.ts
All matched files use the correct format.
$ npx oxlint src/gateway/sessions-patch.ts src/gateway/sessions-patch.test.ts
Found 0 warnings and 0 errors.
$ node scripts/run-tsgo.mjs -p tsconfig.json
(no output = clean)
Observed result after fix: Three new test cases exercise the
@profilesuffix path:persists trailing @profile suffix as authProfileOverride on model patch— a bare@myprofilesuffix setsauthProfileOverride: "myprofile"with source"user".does not set authProfileOverride when profile suffix is missing— plainprovider/modelwithout@leavesauthProfileOverrideundefined.persists full provider:profile authProfileOverride on model patch—@openai-codex:[email protected]is persisted in full, matching the documented credential pinning contract indocs/gateway/authentication.md.All three pass in gateway-core, gateway-server, and gateway-client test environments.
What was not tested: Live Pi + Codex OAuth
@profileend-to-end routing with a real GPT-5.5 turn (requires maintainer-approved live lane). The fix only touches the session patch persistence path — existingsrc/agents/openai-codex-routing.test.tsandsrc/agents/auth-profile-runtime-contract.test.tsalready cover the downstream routing onceauthProfileOverrideis set.Root Cause
resolveModelRefFromString(called byresolveAllowedModelRef→resolveAllowedModelRefFromAliasIndex) usessplitTrailingAuthProfileto strip the@profilesuffix before model resolution, but the extracted profile was never forwarded toapplyModelOverrideToSessionEntry. The function already accepts aprofileOverrideparameter (used by other callers insrc/sessions/model-overrides.ts), but thesessions.patchhandler insrc/gateway/sessions-patch.tsnever extracted or passed it.Fix: call
splitTrailingAuthProfile(trimmed)before model resolution to capture the trailing profile string, then pass it asprofileOverridetoapplyModelOverrideToSessionEntry.Regression Test Plan
src/gateway/sessions-patch.test.tsgains 3 focused cases:@profilesuffix → authProfileOverride set@provider:profilesuffix → authProfileOverride set verbatimsrc/agents/openai-codex-routing.test.tsandsrc/agents/auth-profile-runtime-contract.test.tsUser-visible / Behavior Changes
Users can now use
/model openai/gpt-5.5@openai-codex:[email protected]in sessions and the trailing@profilesuffix will be persisted asauthProfileOverrideon the session entry, matching the documented credential pinning contract. Without this fix, the profile suffix was silently discarded and the user received a misleading provider-routing error.Scope boundary
src/gateway/sessions-patch.ts