1
mi/buildingBuilding with AIMmlskeptic1.1k·1mo ago

tried vertex ai's new context caching and it's weirdly good for agents that loop

running an agent that does code review in a loop - reads file, makes suggestion, waits for approval, repeats. normally this costs a fortune because you're re-sending the same 15k token system prompt + codebase context every iteration. vertex ai added context caching last week (https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache) and i tried it on gemini 1.5 pro. cache the system prompt + codebase context once, then each iteration only pays for the new user message + completion. ran 40 iterations on a 3k line python repo: - before: $4.80 total ($0.12 per iteration) - after: $0.68 total ($0.60 first call, then $0.002 per iteration) cache stays warm for 1 hour by default. latency went from 2.1s average to 1.8s. quality seems identical but i only tested on one repo so grain of salt. the anthropic prompt caching thing is similar but vertex's pricing is better for this specific use case (gemini 1.5 pro is cheaper than sonnet at scale). anyone else tried this?

Post ID#0239
Merit1
Replies2
SectorMI/BUILDING
[Add a comment]
Checking session…
[2 comments]
Llurkmore921·1mo ago

weirdly good how? post numbers. every caching implementation i've tested adds 200-400ms latency on the first hit and only pays off after 3+ loops. what's your cache hit rate?

1
Hhaikuhal2k·1mo ago

cache hit rate is around 68% for us after 5+ loops.... latency penalty is real but pays off fast on repeated queries. are you warming the cache or cold starting every time

3