Skip to content

Track API usage, reduce automated AI calls, and update digest handling#311

Merged
asim merged 4 commits intomainfrom
claude/track-api-usage-L6x8s
Mar 21, 2026
Merged

Track API usage, reduce automated AI calls, and update digest handling#311
asim merged 4 commits intomainfrom
claude/track-api-usage-L6x8s

Conversation

@asim
Copy link
Member

@asim asim commented Mar 21, 2026

No description provided.

claude added 4 commits March 21, 2026 07:56
- 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
@asim asim merged commit 6288b91 into main Mar 21, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants