Repository navigation
fix(llm): apply model.compat.sendSessionAffinityHeaders at openai-tra… - #90033
obuchowski wants to merge 1 commit into
Conversation
|
Codex review: blocked before merge. Reviewed September 26, 2026, 3:02 PM ET / 19:02 UTC (Revision 13). ClawSweeper reviewWhat this changesThe branch forwards session identity through embedded stream wrappers, adds opt-in affinity headers to the older OpenAI-compatible transport, enables them for two Fireworks catalog models, and adds header tests. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain The merged fix at #149615 restores opt-in affinity headers in the managed Chat Completions transport, but it does not enable them in the Fireworks catalog. This PR retains that distinct behavior and session forwarding for provider-selected streams. Its unchanged head also overwrites configured affinity headers, so it is not ready to merge. Priority: P2 Review scores
Verification
How this fits togetherEmbedded agent runs select a model stream and pass request options to the provider transport. The transport combines session-derived and configured headers before sending a model request; the Fireworks catalog supplies model defaults. flowchart LR
A[Agent session] --> B[Stream selection]
C[Fireworks model settings] --> D[Header policy]
B --> D
E[Configured headers] --> D
D --> F[OpenAI compatible transport]
F --> G[Provider request]
Decision needed
Why: Current main supports explicit opt-in, while the branch changes the shipped catalog default and the submitted proof establishes header generation rather than provider-side cache benefit or upgrade behavior. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +48, Tests +62. Total +110 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Carry the remaining session forwarding and any approved Fireworks catalog opt-in onto the current transport, preserving configured headers case-insensitively and verifying fresh and existing configurations through real HTTP requests. Do we have a high-confidence way to reproduce the issue? Yes, from source: a configured affinity header in model.headers is overwritten when this head generates one, while current main's header builder preserves it. The contributor also showed a real Fireworks request reaching the opt-in path. Is this the best way to solve the issue? No. Current main already has the transport repair and safer header precedence; the remaining work should be ported to that owner, with the Fireworks default decided explicitly. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b29a243dcd7f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
|
in version 2026.7.1-beta.5 , not work for models.providers.*.models.0.compat |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks @obuchowski. This regression is already fixed on main by #149615. On b0c330d, a built Gateway sending real agent turns to a local openai-completions receiver sends |
Summary
Fix a regression where model.compat.sendSessionAffinityHeaders stopped being honored after the major inference “gate” moved from
src/llm/providers/openai-completions.tstosrc/agents/openai-transport-stream.ts.Restore the existing affinity-header behavior without losing functionality already provided by src/llm/providers/anthropic.ts and src/agents/openai-completions-compat.ts.
Enable
compat.sendSessionAffinityHeaders: truefor the Fireworks model configurations inopenclaw.plugin.json, because Fireworks prompt caching supports session-affinity routing for repeated session traffic.Success looks like:
x-session-affinity,x-client-request-id, andsession_idheader injection is gated oncompat.sendSessionAffinityHeadersplus a resolved cache/session value, while caller-supplied headers still win through the existing provider request-policy merge.Out of scope: changing provider auth, cache-retention semantics, or session-affinity behavior for providers that do not opt into
compat.sendSessionAffinityHeaders.Pass sessionId to all
wrapEmbeddedAgentStreamFncalls in resolveEmbeddedAgentStreamFnThe codex path already forwarded params.sessionId to wrapEmbeddedAgentStreamFn, but three other call sites omitted it:
Linked context
Closes: N/A
Related:
Fireworks prompt caching documentation:
Real behavior proof
Behavior or issue addressed: Tested with Fireworks Kimi K2.6, a provider/model path where session-affinity headers are used as the prompt-cache routing mechanism. Temporary proof logging was added locally to confirm that the affinity headers are applied on a real OpenClaw request. The proof logging is not part of the PR diff.
Real environment tested:
fireworks/accounts/fireworks/models/kimi-k2p6Exact steps or command run after this patch:
terminal1:
terminal2:
Expected proof shape:
[fw-req] affinity="" sessionId="" sendAffinity=true
Evidence after fix:
The real Fireworks request completed successfully.
The proof log showed that OpenClaw generated the session-affinity headers for the Fireworks request when compat.sendSessionAffinityHeaders was enabled.
Caller-provided request headers remain protected by the existing request-policy merge behavior.
What was not tested:
I did not verify Fireworks billing/cache-hit accounting or provider-side cache-hit metrics.
Proof limitations or environment constraints:
This proof verifies real OpenClaw request shaping and affinity-header emission.
It does not prove measured cache-hit improvement inside Fireworks infrastructure, because that depends on provider-side cache accounting and replica behavior.
Before evidence:
Before this patch, the Fireworks model configuration did not opt into compat.sendSessionAffinityHeaders, and the moved OpenAI-compatible transport path no longer honored the compat flag for Fireworks requests.
Tests and validation
Risk checklist
Did user-visible behavior change? (Yes/No)
No. OpenAI-compatible requests can now include session-affinity headers when the model opts into
compat.sendSessionAffinityHeadersand OpenClaw has a resolved cache/session value but that's not directly visible to user, except smaller cost could be expected.Did config, environment, or migration behavior change? (Yes/No)
No.
Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)
Yes, network request headers can change for opted-in Fireworks model calls. There are no auth or secret-handling changes.
What is the highest-risk area?
OpenAI-compatible request-header shaping.
How is that risk mitigated?
The change is gated on compat.sendSessionAffinityHeaders, preserves the existing request-policy merge behavior so caller-provided headers win, and adds focused regression coverage for the OpenAI-compatible transport path.
Current review state
What is the next action?
Review the updated Fireworks affinity-header behavior and confirm that the real behavior proof is sufficient.
What is still waiting on author, maintainer, CI, or external proof?