Persist stable OpenAI sessions after request aborts#93
Conversation
There was a problem hiding this comment.
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.InstancewhenIMemoryStoredoesn’t implementISessionSearchStore. - 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. |
🤖 Augment PR SummarySummary: This PR ensures OpenAI “stable sessions” are persisted even when the client aborts the HTTP request, and centralizes the session finalization logic. Changes:
Technical Notes: Stable-session persistence is performed best-effort with a dedicated 10s timeout (independent of 🤖 Was this summary useful? React with 👍 or 👎 |
Summary
Tests
GatewayAdminEndpointTests|FullyQualifiedNameCoreServicesExtensionsTests"