feat: reflexion loop token cost tracking#87
Conversation
- Adds a centralized token pricing module (`PRICE_PER_MTOK`) with safe placeholder rates. - Updates `buildRunner` (used across both environments) to accurately aggregate tokens into USD costs according to the defined model pricing. - Gracefully logs warnings and ignores cost tracking for models absent from the pricing configuration. - Adapts and expands tests to explicitly simulate cost consumption and proper budget triggering via `getUsage()`.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Adds a centralized token pricing module (`PRICE_PER_MTOK`) with safe placeholder rates. - Updates `buildRunner` (used across both environments) to accurately aggregate tokens into USD costs according to the defined model pricing. - Gracefully logs warnings and ignores cost tracking for models absent from the pricing configuration. - Adapts and expands tests to explicitly simulate cost consumption and proper budget triggering via `getUsage()`. - Fixes evaluator calibration in scripts/reflexion-eval.ts by updating the critic model.
- Adds a centralized token pricing module (`PRICE_PER_MTOK`) with safe placeholder rates. - Updates `buildRunner` (used across both environments) to accurately aggregate tokens into USD costs according to the defined model pricing. - Gracefully logs warnings and ignores cost tracking for models absent from the pricing configuration. - Adapts and expands tests to explicitly simulate cost consumption and proper budget triggering via `getUsage()`. - Fixes evaluator calibration in scripts/reflexion-eval.ts by updating the critic model.
Implements genuine cost tracking in the Reflexion loop engine.
Previously,
getUsage()falsely stubbed provider costs to zero across the board, bypassing any imposed budget limit. This PR:src/lib/ai/reflexion/pricing.tsas the central repository for operator-maintained token rates.buildRunnerinproviders-env.ts(also utilized byproviders-user.ts) to calculate cost accurately per model.no any) by safely inferring ambiguously typedLanguageModelUsagemetrics.PR created automatically by Jules for task 6043397629124719629 started by @bronz3beard