* fix(ai): prevent websocket cache clobber on concurrent acquire The WebSocket session cache acquire path (expired or non-reusable cached entry) used unconditional delete/set around the connectWebSocket() await. A concurrent request could install a newer entry during that await, which the resuming acquire then clobbered, orphaning the socket that carried the real previous_response_id continuation and corrupting multi-turn Codex conversations. Mirror the release path's owner-checked helpers: delete via deleteOwnedWebSocketSession, and install via a new setOwnedWebSocketSession that only writes when the cache still matches what this acquire left behind (the stale entry, or undefined after removing it / on first connect). A different cached entry means a concurrent request already won the session. The busy-cached branch is unaffected: it returns a transient socket and never writes the cache. * fix(ai): close CAS loser websocket promptly without leaking its socket * fix(ai): correct verifyClient callback type in race regression test * fix(ai): remove unused variable and fix lint in race regression test * test(ai): prove concurrent websocket loser closes --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
@openclaw/ai
Reusable model API contracts, provider adapters, and streaming primitives from OpenClaw. The package supports isolated runtime instances; importing it does not register providers globally.
import { createLlmRuntime } from "@openclaw/ai";
import { registerBuiltInApiProviders } from "@openclaw/ai/providers";
const runtime = createLlmRuntime();
registerBuiltInApiProviders(runtime.registry);
Provider-neutral contracts, validation, diagnostics, and event streams are
available from the package root and focused subpaths such as
@openclaw/ai/event-stream, @openclaw/ai/transports, and
@openclaw/ai/validation. No second OpenClaw runtime package is required.
Provider ids, credentials, model catalogs, retries, and failover remain
application concerns. OpenClaw supplies those policies around this package.
Host policy (request fetch guarding, secret redaction, strict-tool defaults,
provider plugin hooks, and diagnostics logging) can be injected with
configureAiTransportHost; the defaults are inert.
The explicit @openclaw/ai/internal/anthropic, openai, retry-after,
runtime, and shared subpaths exist for the OpenClaw application itself.
They carry no semver guarantee and can change or disappear in any release; do
not depend on them outside OpenClaw.