Skip to content

feat: credit pricing P1+P2 — sync, agent cap, BYOK fee scaffolding#64

Closed
escapeboy wants to merge 1 commit intofeat/credit-pricing-overhaulfrom
feat/credit-pricing-p1-p2
Closed

feat: credit pricing P1+P2 — sync, agent cap, BYOK fee scaffolding#64
escapeboy wants to merge 1 commit intofeat/credit-pricing-overhaulfrom
feat/credit-pricing-p1-p2

Conversation

@escapeboy
Copy link
Copy Markdown
Owner

Summary

Base companion to escapeboy/agent-fleet#TBD (cloud P1+P2). Stacked on PR #63 (P0). Adds:

  • P1-1: `LlmPricingSyncCommand` — Helicone drift sync, graceful no-op in community
  • P2-1: `agents.max_credits_per_call` + Agent::effectiveMaxCreditsPerCall(?Team) precedence helper, EnforceMaxCreditsPerCallAction accepts agentId, BudgetEnforcement threads it from AiRequestDTO, UI gated on Schema::hasColumn
  • P2-5: BYOK platform fee scaffolding — `config('llm_pricing.byok_platform_fee_per_call')` (default 0), Team::effectiveByokPlatformFee() helper. Cloud handles per-team override + actual deduction.
  • P1-3 config: alert thresholds added to `config/llm_pricing.php` (consumed by cloud's EvaluateCostAlertsCommand)

Test plan

  • LlmPricingSyncCommand tests in cloud (covers cloud + base behavior)
  • Agent::effectiveMaxCreditsPerCall tests in cloud
  • All existing budget tests pass
  • Pint clean, PHPStan: no new errors in base

…, agent cap, BYOK fee

Stacked on feat/credit-pricing-overhaul (P0). Closes the P1/P2 backlog.

P1-1 Helicone pricing sync command — `php artisan llm-pricing:sync`. Daily
03:30 cron fetches Helicone aggregator, diffs vs current snapshot, rotates
when drift > 5%. Sanity ceiling at 50% per model triggers manual-review
flag instead of auto-apply. Graceful no-op in community installs.

P2-1 Per-agent max_credits_per_call — Agent gains effective cap helper
with documented precedence (agent → team → config). EnforceMaxCreditsPerCallAction
accepts optional agentId; BudgetEnforcement middleware threads it from
AiRequestDTO. UI exposed in CreateAgentForm + AgentDetailPage gated on
Schema::hasColumn for community-edition compat.

P2-5 BYOK platform fee scaffolding — config('llm_pricing.byok_platform_fee_per_call')
default 0 (current behavior preserved). Per-team override via teams column
(handled in cloud override Team model). Flat fee deducted on BYOK calls
when > 0; distinct log event `platform_credits_byok_fee_charged`.

Cost alerts thresholds added: bleeding_team_ratio, stale_pricing_days,
margin_drift_threshold_pct (consumed by EvaluateCostAlertsCommand in cloud).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@escapeboy escapeboy deleted the branch feat/credit-pricing-overhaul May 4, 2026 12:47
@escapeboy escapeboy closed this May 4, 2026
@escapeboy escapeboy deleted the feat/credit-pricing-p1-p2 branch May 4, 2026 12:47
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.

1 participant