Skip to content

fix(cache): normalize stop param in cache key to prevent fragmentation - #99

Open
permadee wants to merge 1 commit into
Continuum-AI-Corp:mainfrom
permadee:fix/cache-stop-normalization
Open

permadee wants to merge 1 commit into
Continuum-AI-Corp:mainfrom
permadee:fix/cache-stop-normalization

Conversation

@permadee

@permadee permadee commented Sep 14, 2026

Copy link
Copy Markdown

Orca-Code-Review — push 1

Severity Count
P0 0
P1 0
P2 0
P3 0

✅ no blocking findings

The OpenAI wire format accepts stop as either a string or a list of strings. "stop": "foo" and "stop": ["foo"] produce identical upstream behavior, but the cache key used the raw value — so the two forms produced different SHA-256 digests and fragmented the cache.

A client sending stop as a string would always MISS when an earlier client had already warmed the cache with the list form (or vice versa).

Fix: normalize stop to list form ([stop] when isinstance(stop, str)) in the cache key payload so both wire forms hash to the same key.

Tests: tests/unit/test_cache_stop_normalization.py — verifies string vs list equivalence, list ordering, and stability across calls.

The OpenAI wire format accepts stop as either a string or a list of
strings. "stop": "foo" and "stop": ["foo"] produce identical upstream
behavior, but the cache key used the raw value — so the two forms
produced different SHA-256 digests and fragmented the cache.

Normalize stop to a list form in the cache key payload so string and
single-element-list forms share the same cache entry.

@orcacode-review orcacode-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐳 OrcaCode Review

No findings — nothing to flag in this PR. Great work!

OrcaCode Review — Route Smarter. Ship Safer. Spend Less.
Engine-reported: 411 calls · 26M tokens · 98% cached

❤️ Share · Install OrcaCode Review

Free on GitHub — the review runs on your own OrcaRouter key. If it helped, a shout-out goes a long way.

Share: X · Reddit · LinkedIn
Follow: X · Discord · LinkedIn · OrcaRouter

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant