Drop indent=2 from JSON responses to reduce token usage#34
Conversation
LLMs parse compact JSON just as well as indented JSON. Removing indent=2 from all 50 json.dumps calls across 16 tool modules reduces response sizes by 11-22% depending on nesting depth. Benchmarked against live Nextcloud with realistic data: - list_conversations: 8,168 -> 6,890 chars (-15.6%) - get_activity: 10,011 -> 7,955 chars (-20.5%) - list_notifications: 6,002 -> 5,300 chars (-11.7%) - Overall: 27,906 -> 23,394 chars (-16.2%, ~1,289 tokens saved)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (16)
📝 WalkthroughWalkthroughThis pull request removes pretty-printing from JSON responses across 16 tool modules in the MCP server. All changes replace Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #34 +/- ##
=======================================
Coverage 95.88% 95.88%
=======================================
Files 24 24
Lines 1848 1848
=======================================
Hits 1772 1772
Misses 76 76
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
indent=2from all 50json.dumpscalls across 16 tool modulesBenchmark results (against live Nextcloud with realistic data)
Savings scale with data volume — tools returning nested objects (activity, conversations) see 15-22% reduction.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit