Repository navigation
fix(sdk): temperature default should be a float, not a 1-tuple - #18656
Conversation
self.temperature = (0.5,) is a trailing-comma typo. The server-side Memory model stores temperature as a FloatField (default 0.5) and memory_api_service validates it as float, so the SDK attribute should default to the scalar 0.5 like every other scalar default in the SDK.
There was a problem hiding this comment.
Pull request overview
Fixes a Python SDK default value bug where Memory.temperature was accidentally initialized as a 1-tuple (0.5,) due to a trailing comma, ensuring the SDK default matches the server-side FloatField(default=0.5) behavior and avoids leaking list/tuple-shaped values into JSON serialization.
Changes:
- Replace the tuple default
self.temperature = (0.5,)with the intended scalar floatself.temperature = 0.5.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe ChangesMemory temperature initialization
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This change corrects the SDK temperature default from a one-element tuple to the intended numeric value, preventing malformed serialized values when the field is omitted. No actionable merge-blocking risk remains. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
wangq8
left a comment
There was a problem hiding this comment.
Confirmed. The server-side model stores temperature as FloatField(default=0.5) (api/db/db_models.py:1825), and this is the only trailing-comma tuple default in the SDK modules, so (0.5,) is clearly an unintentional typo rather than a deliberate 1-tuple. Changing it to 0.5 matches the server default and removes the latent bug where memory.temperature could leak a list in to_json() / JSON payloads when the field is omitted from a response.
LGTM. Thanks for the fix!
|
LGTM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18656 +/- ##
=======================================
Coverage 90.65% 90.65%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 650 650
Misses 39 39
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Memory.__init__in the Python SDK setsThe parentheses + trailing comma make this a one-element tuple, not a float. It is a trailing-comma typo:
temperatureas aFloatField(default=0.5)(api/db/db_models.py), andmemory_api_service.update_memoryvalidates it withfloat(...).self.progress = 0.0indocument.py).The tuple default is normally masked because the API response includes
temperatureandBase._update_from_dictoverwrites the attribute, but whenever a response omits the field,memory.temperatureleaks the tuple (e.g.str(memory)/to_json()renders"temperature": [0.5], and float comparisons/jsonpayloads get a list instead of a number). Fix is the scalar0.5, matching the server default.