commerce-prompt-caching
Cache-stable request assembly
commerce_common/ is commerce-common/commerce_common/, shopping_agent/ is shopping-agent/core/shopping_agent/, and
merchant_agent/ is merchant-agent/core/merchant_agent/.
The three breakpoints
A request's cacheable prefix runs tools, then system, then the messages; a breakpoint ends a span the next call reads
back. The reference agents place three, all from commerce_common/prompt_assembly.py:
- The last tool:
with_tool_cache_control(tools). - The static system text:
build_system_blocks(static, context)marks it and appends the context block unmarked. - The newest persisted message:
build_request_messages(messages, rolling_breakpoint=...)marks the last persisted block on the outgoing request only; the next call then reads the earlier rounds, search payloads included, from cache.
Everything per request goes in the context block, which the role's build_dynamic_context(...) renders once per turn.
In the static block or the tool list, those bytes would break the system or tool span on every request; in the context block they cost
one re-read of the conversation on a turn whose cart, page, or facts moved, and the rolling marker holds from that turn's
next round. The clock renders to the hour (context_clock), so a new minute moves nothing.