You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(code): rendered code evidence includes checked_at, so identical evidence renders differently on every prepare #2365
_render in src/powercontext/builtin/runtime/prepared_code.py:123 writes checked_at into each citation line of the prepared code context. checked_at is set to the current time on every code query (builtin/code/service.py:427). So when nothing in the repository has changed, two prepares of the same evidence still produce different text.
The text is included in prompts. A client that prepares and injects context on every model request, such as the Rust gateway proposed in #2307, therefore changes the prompt prefix on every request, and provider prompt caching stops working from the injection point onward. Hooks that inject once per user prompt are much less affected, because the injected text then stays fixed in the conversation history.
Steps to reproduce
Configure code indexing for a scope and index a repository.
Call POST /v1/context/prepare twice with the same query and include_code: true.
Compare the two BEGIN_POWERCONTEXT_CODE_V1 blocks.
Expected behavior
The same evidence (same fingerprint, path, file hash, line range, and snippet hash) renders to identical bytes. Freshness can stay in the structured response, outside the prompt text.
Actual behavior
The blocks differ only in checked_at. We measured this with a gateway that injects code evidence on every Codex request on SWE-bench Pro: the prompt-cache hit rate dropped from about 85% to about 40%, and total cost went up. After removing checked_at from the rendered citation (keeping it in the structured candidate), the hit rate returned to the same level as without code injection.
Suggested fix: drop checked_at from the rendered citation. The fingerprint and hashes already identify the evidence exactly.
Related: #2040 (token and latency costs along the context chain).
Activity
fix(code): render identical code evidence without the query time