CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

feat(ai): migrate chat/editor call sites to callModel #5628

Merged⚡ AI-generatedXSccantynz wants to mergefeat/ai-metering-migrate-chatmainopened 18h ago
ccantynzcommented 18h ago

Moves eight direct getAnthropic() + messages.create() callers onto the metered callModel() wrapper (budget refusal → create → outage note → cost recording), shrinking LEGACY_DIRECT_CALLERS by eight.

Migrated

File Category Attribution
src/lib/ai-chat.ts (2 calls) chat none in scope (owner/repo slugs only)
src/lib/ai-pair.ts (2 calls) chat none in scope (PairContext carries no ids)
src/lib/ai-completion.ts other none in scope (IDE plugin path, prefix/suffix only)
src/lib/ai-explain.ts other repositoryId threaded from explainCodebase
src/lib/ai-workspace.ts (2 calls) other job.repoId + triggeredByUserId threaded from the pipeline
src/lib/nl-search.ts (2 calls) other repoId threaded from nlSearch
src/lib/claude-semantic-search.ts other repoId threaded from claudeSemanticSearch
src/routes/ai-editor.ts (3 routes) other session user id (requireAuth)

Behavior preserved

  • Requests byte-identical: same model (passed explicitly via model:), system, messages, max_tokens, temperature.
  • No caller in this set recorded cost before, so nothing double-bills.
  • No .messages.stream( calls in any of these files — nothing left on the legacy list for them.
  • Existing error handling untouched; budget refusals surface through each caller's existing catch/fallback path.

Verification

  • bunx tsc --noEmit clean
  • bun test ai-metering-coverage ai-budget-enforcement — 6 pass
  • bun test ai-explain copilot specs semantic-search — 57 pass
  • bun build src/index.ts --target=bun clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01D9yjyzookEX3DLwpQmFhvu

ccantynzAI Reviewcommented 18h ago

AI Triage

(no summary)

Priority: medium Risk area: mixed

Suggested labels: (no label suggestions) Suggested reviewers: (no reviewer suggestions)

Suggestions only — nothing has been applied. The PR author stays in control.

gluecron[bot]🤖 botAI Reviewcommented 18h ago

AI review unavailable

The platform's AI balance is exhausted, so AI generation is temporarily unavailable. Nothing was lost. You can queue this as a repair for the internal agent from the repository's Health page, or try again once the balance is restored. The PR is otherwise unchanged.

Cross-repo impact

See what breaks downstream if this PR merges.

Analyze →
⮌ Merged

This pull request was merged into main.

c comment · e edit title · m merge · a approve · r request changes · ? shortcuts