Track API usage, reduce automated AI calls, and update digest handling#311
Merged
Track API usage, reduce automated AI calls, and update digest handling#311
Conversation
- Add usage tracking (internal/ai/usage.go) with per-caller token counts, cost estimates, and rolling history of recent calls - Add Caller field to ai.Prompt so every call site identifies itself - Add /admin/ai-usage page showing cost breakdown by caller - Disable article summary generation (biggest cost: ~50 calls/day for RSS articles that already have descriptions) - Disable opinion engagement loop (respond/review/reflect with no users) - Reduce opinion posts from 8/day to 2/day - Reduce community notes from 5/day to 2/day - Increase topic regeneration cache TTL from 1h to 6h Estimated reduction: ~90+ automated AI calls/day eliminated. https://claude.ai/code/session_016UhaM3HefwZjArvB7hHbpE
The digest was stored in its own digests.json and served at /news/digest, which meant it was invisible from the home screen and blog feed. Now it publishes as a regular blog post tagged "digest" using blog.CreatePost, making it visible alongside opinion posts. - Digest creates/updates blog posts via injected callbacks (avoids import cycle) - /news/digest now redirects to the blog post - Social seed thread links to the blog post URL - Home page "Read today's digest" links to /blog?tag=digest - Fixed FindTodayDigest to use AuthorID instead of hardcoded string https://claude.ai/code/session_016UhaM3HefwZjArvB7hHbpE
No users means no need for redirect tech debt. Removed the Handler entirely along with the route registration. FindTodayDigest now uses EqualFold/ToLower for author and tag matching. https://claude.ai/code/session_016UhaM3HefwZjArvB7hHbpE
Delete the entire social/ package (discussions, community notes, fact-checking, seeding, guidelines, filtering). Remove from: - main.go (imports, loading, wiring, routes, seed callbacks) - Nav bar, landing page, home cards - MCP tools (social_list, social_read, social_post, fact_check) - Wallet (OpSocialPost, CostSocialPost, OpFactCheck, CostFactCheck) - Admin flag content type mapping - All docs (README, ARCHITECTURE, SYSTEM_DESIGN, ABOUT, VISION, MCP, MARKETPLACE) - Tests referencing /social paths Also rename /admin/ai-usage to /admin/usage. https://claude.ai/code/session_016UhaM3HefwZjArvB7hHbpE
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.
No description provided.