Skip to content

Persist stable OpenAI sessions after request aborts#93

Merged
Telli merged 2 commits intomainfrom
codex/stable-session-abort-persistence
May 7, 2026
Merged

Persist stable OpenAI sessions after request aborts#93
Telli merged 2 commits intomainfrom
codex/stable-session-abort-persistence

Conversation

@Telli
Copy link
Copy Markdown
Contributor

@Telli Telli commented May 6, 2026

Summary

  • persist accepted stable OpenAI sessions even when the client request aborts
  • centralize OpenAI stable-session finalization shared by chat completions and responses
  • fall back to empty session search for memory backends that do not implement ISessionSearchStore
  • add regression coverage for chat completions and responses abort persistence

Tests

  • dotnet test src/OpenClaw.Tests/OpenClaw.Tests.csproj --filter "FullyQualifiedNameGatewayAdminEndpointTests|FullyQualifiedNameCoreServicesExtensionsTests"

@Telli Telli marked this pull request as ready for review May 6, 2026 23:54
Copilot AI review requested due to automatic review settings May 6, 2026 23:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures OpenAI-compatible “stable sessions” are persisted even when the client aborts the HTTP request, by centralizing session finalization logic shared by both /v1/chat/completions and /v1/responses. It also makes session search optional by providing an empty ISessionSearchStore fallback when the configured memory store doesn’t support searching, and adds regression coverage for the abort/persist scenario.

Changes:

  • Centralized OpenAI session teardown/persistence via FinalizeOpenAiSessionAsync, and adjusted endpoints to persist stable sessions on request aborts.
  • Updated DI to fall back to EmptySessionSearchStore.Instance when IMemoryStore doesn’t implement ISessionSearchStore.
  • Added regression tests validating stable-session persistence after request cancellation for both chat completions and responses.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/OpenClaw.Tests/GatewayAdminEndpointTests.cs Adds regression tests for stable-session persistence when HTTP requests abort; adds a helper to wait for persisted sessions.
src/OpenClaw.Gateway/Endpoints/OpenAiEndpoints.StableSessions.cs Introduces shared FinalizeOpenAiSessionAsync helper to unify stable-session persistence/removal logic.
src/OpenClaw.Gateway/Endpoints/OpenAiEndpoints.ChatCompletions.cs Uses centralized finalization and persists stable sessions even when the request is aborted.
src/OpenClaw.Gateway/Endpoints/OpenAiEndpoints.Responses.cs Uses centralized finalization and persists stable sessions even when the request is aborted.
src/OpenClaw.Gateway/Composition/CoreServicesExtensions.cs Registers ISessionSearchStore with a safe fallback for memory stores that don’t implement search.

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 6, 2026

🤖 Augment PR Summary

Summary: This PR ensures OpenAI “stable sessions” are persisted even when the client aborts the HTTP request, and centralizes the session finalization logic.

Changes:

  • Updates DI to provide an ISessionSearchStore fallback (EmptySessionSearchStore) for memory backends that don’t implement session search.
  • Refactors both /v1/chat/completions and /v1/responses endpoints to share a single FinalizeOpenAiSessionAsync flow.
  • Switches stable-session shutdown behavior from “discard on abort” to “persist on exit” once the binding is accepted.
  • Adds a centralized finalizer that removes ephemeral sessions and best-effort persists stable sessions under a bounded timeout.
  • Adds regression tests covering stable-session persistence when requests are aborted for both chat completions and responses.

Technical Notes: Stable-session persistence is performed best-effort with a dedicated 10s timeout (independent of RequestAborted), and new tests poll the memory store to confirm persistence after client cancellation.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@Telli Telli merged commit 3e69875 into main May 7, 2026
16 checks passed
@Telli Telli deleted the codex/stable-session-abort-persistence branch May 7, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants