Skip to content

OpenRouter compaction/summary requests drop x-session-id when cacheRetention is none #10022

Description

@Shoshkin

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

  1. Use an OpenRouter model and trigger compaction (/compact).
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions