feat(bridge): record prompt-cache breakdown on llm_inference events (bridge-v0.3.3)#3
Merged
Merged
Conversation
3c4b55c to
c4191f3
Compare
The PyO3 bridge transport dropped the prompt-cache breakdown — korgex's KorgBridgeClient already forwarded cache_read_tokens / cache_creation_tokens / uncached_input_tokens (with a TypeError fallback), but record_llm_call didn't accept them, so a cache hit was unprovable from a bridge-written journal while the local-journal and HTTP transports carried it. record_llm_call now takes the three optional cache params and folds them onto the event args ONLY when caching is active (a read or a write happened), mirroring src/korg_ledger.py::_llm_call_args. A cold turn keeps the legacy two-field args, so older readers and the hash-chain over historical events are undisturbed; field order is irrelevant since args are canonicalised with sorted keys at hash time. Bump 0.3.2 -> 0.3.3. Tests: +warm-breakdown / +creation-only cases; 19 bridge tests pass (incl. the chain-integrity suite, so the new field verifies in-chain).
bridge-v0.3.3 entry (matching the existing per-bridge-version convention) and a note in the korg-bridge README that record_llm_call carries the optional prompt-cache breakdown, so a cache hit is provable from a bridge-written journal at parity with korgex's local-journal and HTTP transports.
c4191f3 to
91380d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
korgex now records a provable prompt-cache breakdown on every
llm_inferenceevent (korgex0.25.0). The local-journal and HTTP transports carry it, but the PyO3 bridge dropped it: korgex'sKorgBridgeClientalready forwardedcache_read_tokens/cache_creation_tokens/uncached_input_tokens(with aTypeErrorfallback), but the Rustrecord_llm_calldidn't accept them — so a cache hit was unprovable from a bridge-written journal. This closes that gap.What
record_llm_calltakes three new optional params and folds them onto the eventargsonly when caching is active (a read or a write happened), mirroring korgex'ssrc/korg_ledger.py::_llm_call_argsbyte-for-byte.args, so older readers and the hash-chain over historical events are undisturbed. Field order is irrelevant —argscanonicalize with sorted keys at hash time, the same spec all three independent verifiers use.bridge-v0.3.2 → v0.3.3(Cargo.toml + pyproject +__version__).0.3.3wheel is installed.Test plan
cargo check -p korg-bridgeclean off a freshmainbasematurin develop; 19 bridge tests pass, including:test_record_llm_call_cache_breakdown(warm breakdown lands onargs)test_record_llm_call_cache_creation_only(cache-write-only still records)test_bridge_chain.pysuite — so the new field verifies in-chainbridge-v0.3.3CHANGELOG entry + korg-bridge README noteNotes
This branch was cut clean off
mainand contains only the bridge crate + its docs — no unrelated workspace WIP.