Repository navigation
fix: add missing compat schema keys and session-affinity header injection to transport adapter - #98603
fix: add missing compat schema keys and session-affinity header injection to transport adapter#98603xrayDJ wants to merge 1 commit into
Conversation
…tion to transport adapter Two issues with model compat configuration: 1. ModelCompatSchema in zod-schema.core.ts was missing 8 runtime-supported compat keys (sendSessionAffinityHeaders, sendSessionIdHeader, supportsEagerToolInputStreaming, supportsLongCacheRetention, cacheControlFormat, zaiToolStream, openRouterRouting, vercelGatewayRouting). These are defined in ModelCompatConfig and used throughout the runtime, but because the Zod schema uses .strict() they were silently rejected during config validation. 2. The boundary-aware transport adapter (openai-transport-stream.ts) was missing session-affinity header injection that only the direct adapter had. Since the transport adapter handles all real chat turns, the sendSessionAffinityHeaders compat flag was effectively dead code. Added sessionId param to createOpenAICompletionsClient and buildOpenAICompletionsClientConfig, and pass options?.sessionId through from the call site in createOpenAICompletionsTransportStreamFn.
|
Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 8:37 AM ET / 12:37 UTC. Summary PR surface: Source +82. Total +82 across 2 files. Reproducibility: yes. from source inspection rather than local execution: current main's strict Review metrics: 1 noteworthy metric.
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: Repair the transport change by reusing the typed OpenAI-completions compat resolver or a narrowed model type, add focused schema and header-precedence regression tests, and coordinate the scope with the existing overlapping PRs before merge. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection rather than local execution: current main's strict Is this the best way to solve the issue? No. Adding schema parity is plausible, but the transport fix should use the existing typed completions compat path or narrow the model before reading Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5e4d71686a6a. Label changesLabel justifications:
Evidence reviewedPR surface: Source +82. Total +82 across 2 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
|
|
This pull request has been automatically marked as stale due to inactivity. |
What Problem This Solves
Fixes an issue where users configuring model
compatfields likesendSessionAffinityHeaders,openRouterRouting,vercelGatewayRouting,zaiToolStream,cacheControlFormat,sendSessionIdHeader,supportsEagerToolInputStreaming, orsupportsLongCacheRetentionin their OpenClaw config would have these settings silently dropped during validation. TheModelCompatSchemainzod-schema.core.tsuses.strict(), so any compat key not explicitly declared is rejected even though all 8 are defined inModelCompatConfig, used throughout the runtime, and present in the TypeBox schema inmodel-registry.ts.The
sendSessionAffinityHeaderscompat flag was effectively dead code for real conversations. The boundary-aware transport adapter (openai-transport-stream.ts), which handles all embedded-agent chat turns, never injected session-affinity headers, even when the flag was enabled. Only the direct adapter had this support.Why This Change Was Made
Added all 8 missing compat keys to
ModelCompatSchemawith types matching their declarations inModelCompatConfigand the TypeBox schemas inmodel-registry.ts. This closes the schema drift caused by the Zod schema and the TypeScript/TypeBox types being maintained separately.For session-affinity, added a
sessionIdparameter through the transport adapter call chain (createOpenAICompletionsClient→buildOpenAICompletionsClientConfig) and passoptions?.sessionIdfrom thecreateOpenAICompletionsTransportStreamFncall site. The header injection (session_id,x-client-request-id,x-session-affinity) is gated onmodel.compat?.sendSessionAffinityHeaders, matching the existing direct adapter behavior.Non-goal: the schema and TypeScript types are still maintained separately. A coverage test or shared derivation would prevent future drift, but that's out of scope for this fix.
User Impact
Users can now configure
sendSessionAffinityHeaders,openRouterRouting,vercelGatewayRouting,zaiToolStream, and the other 4 compat fields in theiropenclaw.jsonand have them survive config validation. Providers that rely on session-affinity headers for request routing or caching will now actually receive them during real chat turns, improving cache hit rates and session stickiness whensendSessionAffinityHeadersis enabled.Evidence
Verified the added schema keys and transport adapter changes match the equivalent patches already running in a production OpenClaw deployment (2026.6.9). Side-by-side comparison of all 8 schema entries and all 3 transport adapter changes confirms identical logic, types, and header values. The changes are a schema/transport parity fix, not new functionality.