Copilot commented on code in PR #13654:
URL: https://github.com/apache/apisix/pull/13654#discussion_r3518859325
##########
apisix/plugins/ai-cache/key.lua:
##########
@@ -103,6 +103,10 @@ end
-- ONLY place request-determining data lives; scope() below is pure isolation.
function _M.fingerprint(ctx, body)
local repr = build_repr(ctx, body, client_messages(ctx, body))
+ -- client_messages() (get_messages) flattens structured content to plain
text,
+ -- so an exact fingerprint of it alone would let a text+image prompt
collide
+ -- with a text-only one. Fold the raw messages in to keep them distinct.
+ repr.raw_messages = body.messages
return hex_digest(core.json.canonical_encode(repr))
Review Comment:
Adding `repr.raw_messages = body.messages` unconditionally changes the L1
fingerprint for *all* `messages`-based requests, which will invalidate existing
cache entries even for plain-text prompts. If the intent is only to prevent
collisions for prompts with non-text/tool-call state, consider folding raw
messages into the fingerprint only when such non-text state is actually present.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]