What happened?
Compaction and branch-summary requests to OpenRouter are sent without x-session-id, so OpenRouter logs them as session_id: null. They don't show up under the session in Logs/Analytics/Sessions, and they get no sticky routing.
Cause: these calls set cacheRetention: "none" (#6618). openai-completions.ts and anthropic-messages.ts then drop the session ID completely:
const cacheSessionId = cacheRetention === "none" ? undefined : options?.sessionId;
x-session-id is OpenRouter's routing/observability key and does not write to the cache. The uuidv7() that createSummaryRequestOptions() generates for these calls never reaches the provider.
Steps to reproduce
- Use an OpenRouter model and trigger compaction (
/compact).
- Look up the compaction generation:
GET /api/v1/generation?id=<id> returns session_id: null. Normal turns in the same session have a session ID.
Expected behavior
OpenRouter summary calls keep x-session-id. prompt_cache_key and cache_control stay omitted under cacheRetention: "none".
I'd like to submit the fix. It's OpenRouter-only, so other session-affinity formats are unchanged: Shoshkin/pi@main...fix/openai-completions-session-affinity-cache-none
This reverses the cache-disabled part of bbb61e3 (#9102) for OpenRouter. Happy to adjust if that was intentional.
Version
0.85.1, still present on main (0.87.1)
AI disclosure: the investigation, fix and this text were drafted with Claude Code and reviewed by me.
What happened?
Compaction and branch-summary requests to OpenRouter are sent without
x-session-id, so OpenRouter logs them assession_id: null. They don't show up under the session in Logs/Analytics/Sessions, and they get no sticky routing.Cause: these calls set
cacheRetention: "none"(#6618).openai-completions.tsandanthropic-messages.tsthen drop the session ID completely:x-session-idis OpenRouter's routing/observability key and does not write to the cache. Theuuidv7()thatcreateSummaryRequestOptions()generates for these calls never reaches the provider.Steps to reproduce
/compact).GET /api/v1/generation?id=<id>returnssession_id: null. Normal turns in the same session have a session ID.Expected behavior
OpenRouter summary calls keep
x-session-id.prompt_cache_keyandcache_controlstay omitted undercacheRetention: "none".I'd like to submit the fix. It's OpenRouter-only, so other session-affinity formats are unchanged: Shoshkin/pi@main...fix/openai-completions-session-affinity-cache-none
This reverses the cache-disabled part of bbb61e3 (#9102) for OpenRouter. Happy to adjust if that was intentional.
Version
0.85.1, still present on main (0.87.1)
AI disclosure: the investigation, fix and this text were drafted with Claude Code and reviewed by me.