-
Notifications
You must be signed in to change notification settings - Fork 525
Fix: Remove unused cost_usd field #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a thing anymore -- the field is total_cost_usd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude can you kill the cost_usd fields and replace them with total_cost_usd?
The CLI only sends total_cost_usd, not cost_usd. This PR: - Removes the non-existent cost_usd field from ResultMessage - Makes total_cost_usd optional since it may be missing - Handles GeneratorExit gracefully in subprocess transport - Removes unnecessary cancel scope call Fixes the error users were experiencing: - KeyError: 'cost_usd' - Field required [type=missing, input_value=...] The anyio cancel scope error still appears in logs but doesn't affect functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
2444c44 to
6cc5b34
Compare
- Remove cost_usd field from test expectations - Update to use total_cost_usd instead of total_cost - All 30 tests now pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @ltawfik's task —— View job PR Review: Fix Optional Cost FieldsTodo List:
Code Review SummaryThis PR addresses an important compatibility issue by making cost fields optional, but there's one critical issue that needs to be fixed. 🚨 Critical Issue
# Current (incorrect):
elif isinstance(message, ResultMessage) and message.cost_usd > 0:
# Should be:
elif isinstance(message, ResultMessage) and message.total_cost_usd and message.total_cost_usd > 0:✅ Code Quality & Best PracticesGood implementations:
✅ Bug PreventionThe changes successfully prevent
✅ Performance Considerations
✅ Security Concerns
✅ Test CoverageThe test suite has been properly updated:
📋 Workflow FilesThe added GitHub workflows are well-configured:
RecommendationAPPROVE with one required fix: Update After that fix, this PR will successfully resolve the validation errors while maintaining backward compatibility. |
732e15c to
b3448f4
Compare
Summary
cost_usdandtotal_cost_usdfields optional in ResultMessage.get()Problem
Users are experiencing KeyError and validation errors when using the Python SDK because:
cost_usdin its responsetotal_costtototal_cost_usdSolution
This PR makes both cost fields optional with None defaults and uses safe dictionary access to handle missing fields gracefully.
Test plan
🤖 Generated with Claude Code