Repository navigation
Conversation
get_decision_point_assignment now asks /assign for just the decision point it was given when the cache can't answer, and caches the result for that decision point, matching the JS and Java client libs. - DataService tracks whether a full-context response filled the cache. get_all_experiment_conditions only returns a full-context cache, so a cache holding single decision points makes it fetch the full context. - A decision point with no assignment isn't cached, so it's asked again. - mark_decision_point no longer fetches assignments when the cache is cold. It sends the cached assignment's ids, so a decision point that was never looked up is marked without them (same as JS and Java). - README and CLIENT_API_COVERAGE.md updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Layout-only: ruff format --check was already failing on these files on dev. No code changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Focused Thompson Sampling lookups can cache conflicting conditions for the same experiment, allowing exposure and reward attribution to disagree with persisted enrollment.
1 open issue
What changed in this PR
Adds optional /assign decision-point support to the Python client, aligning its focused lookup and mark behavior with the JS and Java clients.
Changes:
- Sends focused assignment requests and distinguishes partial caches from full-context caches.
- Removes automatic assignment fetching from
mark_decision_point, while preserving cached IDs when available. - Adds request and cache tests, updates documentation, and applies formatting cleanup.
| File | Description |
|---|---|
clientlibs/python/tests/test_types.py |
Tests optional decision-point request fields. |
clientlibs/python/tests/test_data_service.py |
Tests partial-cache lifecycle and full-context replacement. |
clientlibs/python/tests/test_client.py |
Tests focused lookups, caching, older-server responses, and mark behavior. |
clientlibs/python/tests/test_api_service.py |
Tests decision-point serialization and target normalization. |
clientlibs/python/src/upgrade_client_lib/types/requests.py |
Adds optional decisionPoint to AssignRequest. |
clientlibs/python/src/upgrade_client_lib/data_service.py |
Tracks partial versus full-context assignment caches. |
clientlibs/python/src/upgrade_client_lib/client.py |
Implements focused lookups and removes fetching during marks. |
clientlibs/python/src/upgrade_client_lib/assignment.py |
Formatting only; no behavior change. |
clientlibs/python/src/upgrade_client_lib/api_service.py |
Builds focused /assign bodies for async and sync requests. |
clientlibs/python/README.md |
Documents lookup, caching, and mark behavior changes. |
clientlibs/CLIENT_API_COVERAGE.md |
Marks Python decision-point support as implemented and tested. |
Review effort: Balanced
Comment on lines
+72
to
+73
| for a in assignments: | ||
| cached.setdefault(self._key(a.site, a.target), a) |
Collaborator
Author
There was a problem hiding this comment.
This is the same issue that we decided not to worry about in the ts pr - it's also apparently a thing in the java one.
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.

Brings the Python client lib into parity with the JS (#3425) and Java client libs for the optional
decisionPointin the/assignbody.Changes
get_decision_point_assignment(async and_sync)get_all_experiment_conditionsalready fetched the full context, or an earlier call fetched this decision point./assignwithdecisionPoint: {site, target}(aNonetarget is sent as""), so the server evaluates only that decision point, and caches the response for it.decisionPointreturns the full context. That still answers the lookup but isn't treated as the full context.get_all_experiment_conditionsonly returns a cache that a full-context fetch filled. If the cache holds only single decision points, it fetches the full context.mark_decision_pointno longer fetches assignments. Previously, marking with a cold cache fetched the full context first so the mark could carry the cachedexperimentId/condition id. JS and Java never fetch on mark, so Python now matches them: a decision point that was never looked up is marked without those ids, and the server selects the experiment itself. Callers who look the decision point up before marking (the README pattern) are unaffected.Docs: the README method table and Caching section are updated, and the Python cell of the
/assigndecisionPointrow inCLIENT_API_COVERAGE.mdis now ✅.The second commit is layout-only
ruff formaton 5 files that were already failingruff format --checkondev. Review the first commit on its own to skip it.Testing
ApiService,DataServiceand request types).ruff check,ruff format --checkandmypyare clean.🤖 Generated with Claude Code