Add effective_cache_key(model, context) helper - #265
Merged
Conversation
Expose a public helper that returns the effective identity key for evaluating a model on a context, given the model and context directly rather than a ModelEvaluationContext. cache_key(..., effective=True) already derives effective identity, but only for a ModelEvaluationContext. Callers that hold a bare model plus a context (for example keyed persistent caches) otherwise have to reconstruct a ModelEvaluationContext and compare structural versus effective keys to detect opt-out models. This helper wraps the existing internal derivation instead: models that declare an effective identity are keyed by it, and models that do not fall back byte-for-byte to cache_key(model). Signed-off-by: Pascal Tomecek <40371786+ptomecek@users.noreply.github.com>
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
=======================================
Coverage 93.53% 93.53%
=======================================
Files 176 176
Lines 20460 20494 +34
Branches 1352 1352
=======================================
+ Hits 19137 19170 +33
- Misses 1052 1053 +1
Partials 271 271 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ptomecek
marked this pull request as ready for review
August 25, 2026 16:39
feussy
approved these changes
Aug 25, 2026
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.
Summary
Adds a public helper
effective_cache_key(model, context)toccflow.evaluators.common.cache_key(..., effective=True)already derives effective (opt-in) identity, but only for aModelEvaluationContext. Callers that hold a bare model plus a context — for example keyed persistent caches — otherwise have to build a throwawayModelEvaluationContextand then compare the structural and effective keys to detect opt-out models. This helper wraps the existing internal derivation directly:Noneidentity payload) are keyed by it.cache_key(model).cache_key(mec, effective=True), the result is the model-level effective key without the surrounding evaluation-context envelope (fn/options), and opt-out models get the context-independent structural key rather than a context-dependent one.No behavior change to existing APIs — this is purely additive (new public function +
__all__entry).Tests
TestEffectiveCacheKeycovers: opt-out equalscache_key(model)and is context-independent; opt-in is keyed by the identity payload (and collapses contexts the payload treats as equivalent); payload-relevant differences produce distinct keys; and errors raised inside an identity payload propagate rather than being masked by the structural fallback.ruff checkclean;ccflow/tests/evaluators/test_common.py(45) and the effective-key characterization suite pass.