Repository navigation
Conversation
What changed: - preserve opaque bare UUID session keys in gateway session-store resolution instead of canonicalizing them to agent-scoped keys - normalize Control UI chat URLs from agent:main:<uuid> back to the original bare UUID and keep that normalized form when syncing the URL - pass agent context into transcript lookup so agent-scoped session stores resolve the correct transcript file - add regression coverage for the gateway, transcript-path fallback, and Control UI URL normalization flows - include the new app-settings regression file in the active Vitest unit suites Why: - Open WebUI uses opaque UUID chat ids for its conversations while OpenClaw's gateway and Control UI usually canonicalize bare keys into agent-prefixed session keys - that mismatch can split one Open WebUI conversation into a bare UUID session and an agent:main:<uuid> session, which makes history look missing or incomplete depending on which path is opened - the bug is narrow to the Open WebUI integration path, but it breaks the multi-chat workflow that makes Open WebUI useful as a ChatGPT-style frontend for OpenClaw Impact: - Open WebUI and OpenClaw Control UI now converge on the same session key for main-agent UUID chats - opening an Open WebUI chat in Control UI reuses the existing history instead of creating a second session shell - session history loading follows the agent-scoped transcript location consistently for these chats Validation: - pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.fs.test.ts -t "uses agentId fallback to read agent-scoped transcripts from OPENCLAW_HOME" - pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.test.ts -t "preserves opaque bare UUID session keys" - pnpm exec vitest run --config vitest.unit.config.ts ui/src/ui/app-settings.test.ts - manually verified on the deployed Open WebUI + Control UI flow that the same UUID chat opens with shared history instead of splitting into a second session
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 652d131924
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (looksLikeSessionId(rawLower)) { | ||
| return rawLower; |
There was a problem hiding this comment.
Keep legacy agent-scoped UUID keys addressable
Returning bare UUIDs here drops the legacy agent:<id>:<uuid> alias path for upgraded stores. In deployments that already persisted keys like agent:main:<uuid>, a bare UUID from Open WebUI (or the Control UI URL normalization added in ui/src/ui/app-settings.ts) no longer resolves to the existing store entry, because lookup scans only the bare key/case variants and never the agent-prefixed UUID form; sessions.get then returns an empty history for an existing chat. Please preserve a fallback alias/migration path so pre-existing prefixed UUID sessions remain readable after upgrade.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR fixes a narrow but real session-identity split that occurs when the same UUID-backed Open WebUI chat is opened in the OpenClaw Control UI. Three orthogonal changes accomplish this: (1) the gateway's Confidence Score: 4/5Safe to merge for the current Open WebUI (UUID v4) use case; one regex tightness issue could reintroduce the bug for v6/v7 UUIDs in a future Open WebUI release. The fix is correct and well-tested for the stated scope (UUID v4 Open WebUI sessions). A single concrete divergence between the UI's
|
| Filename | Overview |
|---|---|
| src/gateway/session-utils.ts | Adds looksLikeSessionId guard in both canonicalizeSessionKeyForAgent and resolveSessionStoreKey to bypass agent-prefixing for bare UUID keys. Logic is correct and the guard is placed before any canonicalization path. |
| src/gateway/session-utils.fs.ts | Threads the optional agentId param through readSessionMessages → resolveSessionTranscriptCandidates. Existing callers pass undefined and retain current behavior; the new gateway handler passes an inferred agentId to find agent-scoped transcripts. |
| src/gateway/server-methods/sessions.ts | Infers agentId from the target's canonical key (falling back to the default agent) before calling readSessionMessages. For bare UUID keys parseAgentSessionKey returns null so the default agent is used — correct for the Open WebUI use case. |
| ui/src/ui/app-settings.ts | Adds normalizeChatUrlSessionKey to strip agent:main:<uuid> prefixes from URL session params and propagates it through applySettingsFromUrl, syncUrlWithTab, and syncUrlWithSessionKey. One issue: the local looksLikeUuid regex is more restrictive than the gateway's SESSION_ID_RE, leaving v6/v7 UUIDs un-normalized. |
| src/gateway/session-utils.test.ts | Two new unit tests validate bare UUID preservation in resolveSessionStoreKey and in the combined store. Coverage is solid for the primary happy path. |
| src/gateway/session-utils.fs.test.ts | New filesystem integration test validates the agentId fallback transcript lookup path using a temp dir and OPENCLAW_HOME stub. Test properly restores env with finally/unstubAllEnvs. |
| ui/src/ui/app-settings.test.ts | Adds coverage for normalizeChatUrlSessionKey (round-trip and identity cases), applySettingsFromUrl URL normalization, and syncUrlWithSessionKey. The added setTestWindowUrl in setTabFromRoute's beforeEach also improves test isolation. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: ui/src/ui/app-settings.ts
Line: 41-43
Comment:
**UUID regex diverges from gateway-side `SESSION_ID_RE`**
The gateway uses `SESSION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i` (accepts any hex UUID), while this helper enforces RFC 4122 versions `[1-5]` and variant bits `[89ab]`. Any UUID that the gateway preserves as a bare key but whose version nibble is outside the range `1–5` — notably **UUID v6** and **UUID v7** — will not be stripped of the `agent:main:` prefix by this function.
Concretely: if a future Open WebUI release uses v7 UUIDs (a growing pattern), a URL with an `agent:main:<v7-uuid>` session param would not be normalized by `normalizeChatUrlSessionKey`, and the user would end up with the prefixed form stored in settings — recreating the same split-identity bug this PR is meant to fix.
The simplest fix is to align with the already-established `SESSION_ID_RE` semantics, either by importing `looksLikeSessionId` from `../../../src/sessions/session-id.js` or by dropping the version and variant constraints here:
```suggestion
function looksLikeUuid(value: string): boolean {
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Preserve Open WebUI UUID sessions across..." | Re-trigger Greptile
What changed: - add a legacy agent-scoped UUID alias to gateway session-store scan targets so upgraded stores still resolve old `agent:<id>:<uuid>` entries - switch Control UI URL normalization to the shared `looksLikeSessionId` helper instead of a narrower local UUID regex - add regression tests for the legacy alias path and for future UUID variants that still match the gateway session id format Why: - automated review surfaced two real edge cases in the original Open WebUI fix - upgraded installs could lose history for chats that were previously stored under `agent:main:<uuid>` once the Control UI starts normalizing those URLs back to bare UUIDs - the UI regex also diverged from the gateway-side session id matcher, which could recreate the same split bug for newer UUID versions Impact: - pre-existing prefixed Open WebUI chat keys remain readable after upgrade - the Control UI and gateway now agree on which UUID strings should be treated as opaque session ids Validation: - pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.test.ts -t "resolveSessionStoreKey preserves opaque bare UUID session keys" - pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.test.ts -t "resolveGatewaySessionStoreTarget keeps legacy agent-scoped UUID aliases addressable" - pnpm exec vitest run --config vitest.unit.config.ts ui/src/ui/app-settings.test.ts -t "normalizeChatUrlSessionKey"
|
Addressed both automated review comments in e9bd322.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9bd3225e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const legacyAgentScopedUuidKey = looksLikeSessionId(params.canonicalKey) | ||
| ? `agent:${params.agentId}:${params.canonicalKey}` | ||
| : null; |
There was a problem hiding this comment.
Add bare UUID lookup for agent-scoped UUID keys
buildGatewaySessionStoreScanTargets only adds the legacy alias in one direction (<uuid> → agent:<id>:<uuid>). After this change, bare-key mutations can prune the prefixed legacy key, but lookups that still use agent:main:<uuid> (older Control UI links/clients) never probe the bare UUID key, so sessions.get/preview resolve as missing and show empty history. Please include the reciprocal fallback (agent:<id>:<uuid> → <uuid>) so upgraded stores remain readable from both key forms.
Useful? React with 👍 / 👎.
What changed: - extend gateway session-store scan targets to probe the bare UUID form when the incoming key is the legacy agent-scoped UUID alias - add a regression test that covers prefixed legacy links resolving a store entry that already lives under the bare UUID key Why: - the earlier Open WebUI fix preserved upgraded prefixed UUID sessions when a bare UUID lookup arrived, but older Control UI links could still arrive in the opposite direction as agent:main:<uuid> - without the reciprocal fallback, upgraded stores could still look empty for those legacy links even though the chat had already converged onto the bare UUID form Impact: - Open WebUI UUID chats remain readable from both old prefixed links and the normalized bare UUID form during and after migration Validation: - pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.test.ts - pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.fs.test.ts - pnpm exec vitest run --config vitest.unit.config.ts ui/src/ui/app-settings.test.ts - note: src/gateway/session-utils.test.ts still includes a pre-existing unrelated baseline failure in uses persisted active subagent runs when the local worker only has terminal snapshots; the new Open WebUI UUID tests pass in that run
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: abdc6ae340
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (parsed.agentId !== "main") { | ||
| return raw; |
There was a problem hiding this comment.
Normalize legacy UUID links for any default agent
normalizeChatUrlSessionKey only strips the agent: prefix when agentId === "main", but legacy UUID links were previously generated with whatever agent was configured as default (for example agent:ops:<uuid>). In those setups this migration path is skipped, so Control UI keeps the prefixed key and can continue flipping session aliases instead of converging on the bare UUID form, which defeats the intended Open WebUI session unification for non-main defaults.
Useful? React with 👍 / 👎.
Resolve the two PR merge conflicts in vitest include lists by keeping the new upstream unit test patterns (`packages/**/*.test.ts`, `ui/src/ui/chat/**/*.test.ts`) alongside the Open WebUI regression entry for `ui/src/ui/app-settings.test.ts`.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 572bdf66ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (looksLikeSessionId(lowered)) { | ||
| return lowered; |
There was a problem hiding this comment.
Preserve agent scope for UUID keys in combined store
Returning bare UUIDs in canonicalizeSessionKeyForAgent drops the originating agent identity while loadCombinedSessionStoreForGateway is merging per-agent stores. With default per-agent store paths, this makes a UUID session from a previously-default agent appear as an unscoped key in sessions.list; later sessions.get/patch/delete resolve that bare key against the current default agent store and can return empty history or miss the row entirely. This regression is user-visible after changing the default agent (or when multiple agent stores are present), so UUID keys need to retain enough agent scoping for round-trips.
Useful? React with 👍 / 👎.
| if (looksLikeSessionId(rawLower)) { | ||
| return rawLower; |
There was a problem hiding this comment.
Canonicalize UUID aliases before message subscription keys
The new UUID early-return keeps <uuid> canonical as bare, while agent:main:<uuid> still canonicalizes to its prefixed form, so the same session can now have two canonical keys. Session-message subscriptions and transcript fan-out use exact string keys (see sessions.messages.subscribe and sessionMessageSubscribers.get(...)), which means a legacy client subscribed on agent:main:<uuid> will miss live message events emitted under the bare UUID key. Normalizing both aliases to one canonical subscription key (or subscribing/emitting both forms) avoids this split stream.
Useful? React with 👍 / 👎.
…session-fix-v2026.3.24
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 519a0b903b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (looksLikeSessionId(rawLower)) { | ||
| return rawLower; |
There was a problem hiding this comment.
Resolve mainKey alias before UUID normalization
The new UUID fast-path returns early for any bare UUID-shaped key, so a configured session.mainKey that happens to look like a UUID no longer maps to the canonical main session key. In that configuration, resolveSessionStoreKey({ sessionKey: <mainKey> }) now returns the bare UUID instead of agent:<default>:<mainKey>, which splits history and breaks clients that use the configured main-key alias. This regression is introduced by checking looksLikeSessionId(...) before the existing rawMainKey alias handling.
Useful? React with 👍 / 👎.
What changed: - reintroduced a runtime agent.getApiKey hook in the embedded attempt path so custom providers can resolve credentials through modelRegistry.getApiKeyForProvider - wrapped agent.streamFn in applyExtraParamsToAgent with a dedicated Codex proxy transport selector - added codex-proxy-transport.ts so openai-codex-responses models on non-ChatGPT base URLs can use the proxy-aware WebSocket transport instead of the default simple transport - preserved bearer auth while synthesizing a separate chatgpt-account-id when proxy transports do not provide one explicitly - cleaned up a constant-truthiness error branch in the proxy transport so the staged files pass the repository lint gate Why: - direct embedded codex-lb runs had been failing because the embedded runtime lost provider credentials after the auth-aware stream path was replaced - even after credentials were restored, Codex-style proxy backends still needed a different transport contract than the default ChatGPT/OpenAI path - these changes keep generic embedded runs working while allowing non-OpenAI Codex proxy endpoints to speak the backend /codex/responses transport they actually expect Impact: - embedded sessions can once again resolve runtime API keys for custom providers such as codex-lb - models using openai-codex-responses on proxy base URLs can take the dedicated WebSocket transport path instead of being forced through the default streamSimple contract - standard providers continue using the existing transport path unless the model explicitly matches the proxy Codex criteria
What changed: - imported resolveAgentRoute into the gateway send handler - when callers omit explicitAgentId and sessionKey but provide an accountId, derive a routedAgentId from the configured channel/account route before falling back to the default agent - kept the existing explicit agent and session-derived agent precedence intact Why: - outbound sends that targeted a bound account such as the paperclip Telegram account could still mirror into the default main agent session when no sessionKey was supplied - that made manual sends land in the wrong agent context even though the route configuration already knew which agent owned the account Impact: - account-scoped sends can now inherit the bound agent route automatically - mirrored session keys and agent ownership stay aligned with the configured channel route instead of drifting back to the default agent when sessionKey is omitted
What changed: - added a compat auth resolver inside compaction-safeguard.ts that accepts getApiKeyAndHeaders, getApiKeyForProvider, or the legacy getApiKey method on ctx.modelRegistry - preserved the existing headers-aware safeguard contract so compaction can still proceed when auth is supplied through request headers rather than only a raw API key - switched the safeguard entrypoint to use that compat resolver before deciding whether compaction must be cancelled - exported the resolver through __testing and added focused regression coverage in compaction-safeguard.test.ts for new-model-registry auth resolution and the unsupported-interface error case Why: - manual and automatic compaction were still calling ctx.modelRegistry.getApiKey(model) directly - newer pi-coding-agent model registries no longer expose that method, which caused compaction safeguard to cancel with ctx.modelRegistry.getApiKey is not a function - the embedded runtime had already been patched to use getApiKeyForProvider, so compaction was the remaining incompatible auth path Impact: - compaction safeguard can resolve request auth on both old and new model registry interfaces - custom providers such as codex-lb no longer fail compaction solely because the registry dropped the legacy getApiKey method - the fix is covered by targeted safeguard tests that passed on the server checkout before commit
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f24a8e1f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let socket: WebSocketLike; | ||
|
|
||
| try { | ||
| socket = new WebSocketCtor(url, { headers: wsHeaders }); |
There was a problem hiding this comment.
Use a WebSocket client that supports custom headers
connectWebSocket instantiates globalThis.WebSocket with { headers: ... }, but in Node/Bun the standard WebSocket constructor only accepts a protocols argument, so these auth headers are not transmitted. That means Authorization/chatgpt-account-id from buildWebSocketHeaders are effectively dropped for proxied openai-codex-responses calls, which can cause authentication/tenant routing failures for every request using this transport.
Useful? React with 👍 / 👎.
| model: model.id, | ||
| store: false, | ||
| stream: true, | ||
| instructions: context.systemPrompt, |
There was a problem hiding this comment.
Avoid duplicating the system prompt in Codex payloads
The request body sets instructions: context.systemPrompt, while convertResponsesMessages(...) already injects the same context.systemPrompt as an input system/developer message. Sending both duplicates prompt content on every call, which increases token usage and can change model behavior (or hit context limits sooner) for long prompts.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 12:28 PM ET / 16:28 UTC. Summary PR surface: Source +1278, Tests +252, Other +2. Total +1532 across 15 files. Reproducibility: yes. at source level: current main still sends non-agent raw session keys through agent-scoped canonicalization, matching the linked Open WebUI UUID split. I did not run a live Open WebUI setup in this read-only review. Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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:
Proof path suggestion Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Land a narrow UUID-preservation or shared raw-alias session repair against the current session-accessor architecture, with upgrade tests and real Open WebUI plus Control UI proof, and move the Codex/provider transport changes to separate review. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main still sends non-agent raw session keys through agent-scoped canonicalization, matching the linked Open WebUI UUID split. I did not run a live Open WebUI setup in this read-only review. Is this the best way to solve the issue? No. Preserving UUID session identity is a plausible repair, but this branch is too broad, stale, and conflicting; the best fix is a narrow session-key repair or shared raw-alias contract on the current session-accessor boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 70f2bef6b4cf. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1278, Tests +252, Other +2. Total +1532 across 15 files. View PR surface stats
Security concerns:
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
Review history (2 earlier review cycles)
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks @SHAREN for the detailed reproduction and investigation. Closing this older implementation in favor of the canonical report #86743 and the broader shared-alias repair in #83368. The underlying raw/canonical session split is not being dismissed; it remains open there. This branch is no longer a safe implementation vehicle: sessions and transcripts moved to SQLite in #98236, the Control UI architecture changed in #100024, the UUID shortcut loses agent ownership in multi-agent stores, and the branch bundles unrelated legacy Codex transport/auth routing. #83368 addresses the alias contract across lookup and mutation paths on the current owner boundary. If a distinct Open WebUI-specific failure remains after that work, please add current-version proof to #86743. Thank you for surfacing the original split-session failure. |
Summary
agent:main:<uuid>in the gateway session storeagent:main:<uuid>back to the original bare UUID when the Control UI reads or writes chat URLsProblem
Open WebUI uses opaque UUIDs for chat ids. When the same chat is opened through the OpenClaw Control UI, OpenClaw currently treats that UUID like an ordinary bare session key and canonicalizes it into an agent-prefixed key.
In practice, one Open WebUI conversation can end up with two identities:
aa28595d-ef49-4381-b332-e3c990300d74agent:main:aa28595d-ef49-4381-b332-e3c990300d74Once that happens, the Control UI can open an empty shell instead of the real Open WebUI conversation, or it can miss the existing transcript even though the messages are already present on disk.
This is a narrow integration bug rather than a broad session cleanup issue. It shows up when Open WebUI is used as a multi-chat frontend for OpenClaw and the same UUID-backed chat is later opened in the Control UI.
Why this matters
Open WebUI is a useful ChatGPT-style frontend for OpenClaw because it makes it easy to keep multiple long-running topic-specific chats in the browser. Without this fix, that workflow still requires a downstream monkey patch after upgrades, because the shared Open WebUI/OpenClaw session identity drifts apart.
What changed
agent:main:<uuid>URLs back to the original bare UUID and keeps that normalized form in the address bar.agentIdthrough transcript lookup so agent-scoped stores resolve the right transcript path for these chats.Scope
This PR intentionally stays focused on shared session identity and transcript lookup for Open WebUI-backed chats.
It does not try to mirror external turns into Open WebUI's own SQLite history database. That visual-sync behavior is a separate follow-up concern.
Testing
pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.fs.test.ts -t "uses agentId fallback to read agent-scoped transcripts from OPENCLAW_HOME"pnpm exec vitest run --config vitest.gateway.config.ts src/gateway/session-utils.test.ts -t "preserves opaque bare UUID session keys"pnpm exec vitest run --config vitest.unit.config.ts ui/src/ui/app-settings.test.tsv2026.3.24: opening the same UUID-backed chat in the Control UI reused the existing history instead of splitting into a second sessionFixes #49202