Implement support for OpenRouter sticky routing via a session_id variable

This commit is contained in:
2026-07-02 20:08:44 -05:00
parent 4d4bb7a121
commit 63fb8fc132
19 changed files with 363 additions and 13 deletions

View File

@@ -26,6 +26,7 @@ Example:
Serialized JSON fields:
- `model` (required after fallback resolution)
- `session_id` (only when the rendered prompt includes a non-empty session ID)
- `messages` (rendered prompt messages)
- `temperature` (only when non-zero)
- `max_tokens` (only when non-zero)
@@ -35,6 +36,8 @@ Serialized JSON fields:
`service_tier` is provider-specific. OpenRouter currently documents request values such as `flex` and `priority`; Scriptorium forwards any non-empty configured value and lets the backend validate support.
`session_id` is rendered from prompt YAML using request variables and serialized as a top-level JSON request field. Scriptorium does not send an `x-session-id` header. Empty rendered session IDs are omitted, and values longer than 256 characters are rejected before the HTTP request.
Messages without prompt cache control serialize with string `content`:
```json
@@ -140,7 +143,7 @@ The following fields may exist in profile/effective settings but are not current
- `reasoning_effort`
- `extra_params`
The client also does not serialize top-level `cache_control` or `session_id`.
The client also does not serialize top-level `cache_control`.
No built-in retries, tool-calls, or multi-request payload modes are implemented in this client.