本文へ移動
cccskills
無料GitHub で公開

agent-rate-limit-strategy

Control LLM spend and Apex governor exposure for high-traffic Agentforce agents via per-user token budgets and graceful fallback when the budget is exhausted. NOT for reducing tokens per conversation in the first place — use agentforce/agentforce-cost-optimization. NOT for API rate-limiting of Salesforce REST endpoints — use integration/api-governance-and-rate-limits.

インストール方法を見る

含まれるファイル(7)

  • SKILL.md3.7 KB
  • references/examples.md5.3 KB
  • references/gotchas.md868 B
  • references/llm-anti-patterns.md7.1 KB
  • references/well-architected.md2.1 KB
  • scripts/check_agent_rate_limit_strategy.py940 B
  • templates/agent-rate-limit-strategy-template.md552 B

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Agent Rate Limit Strategy

Agentforce exposes internal LLM quotas indirectly — you hit them as platform 503s with no forward signal. This skill builds a client-side budget gate in front of the agent: per-user token ledger, CMDT-driven thresholds, and a graceful fallback when the budget is exhausted.

Recommended Workflow

  1. Define budget: tokens/user/hour, tokens/tenant/day. Persist in Agent_Rate_Limit__mdt per-persona.
  2. In the channel entry point (LWC wrapper or Connect API), call a BudgetService.checkAndConsume(userId, estTokens) before dispatching to the agent.
  3. Log consumption via Platform Event Agent_Token_Consumed__e — the subscriber rolls into a User_Token_Ledger__c aggregate.
  4. When the budget is exhausted, render the fallback UX (human handoff / retry-after message) instead of calling the agent.
  5. Dashboard: p50/p95 consumption per persona, budget exhaustion count, tokens/turn — page SRE when exhaustion >1%.

Key Considerations

  • Estimate tokens conservatively from input length (chars/4) before the call; reconcile after.
  • Ledger is eventually consistent — use the Platform Event pattern, not synchronous DML.
  • Fallback UX must be pre-approved; a generic 'try again later' erodes trust.

Worked Examples (see references/examples.md)

  • Budget service sketch — 100 Service reps use agent summarization; one rep loops a bad input 500x.
  • Graceful fallback — Budget exhausted mid-conversation.

Common Gotchas (see references/gotchas.md)

  • Estimating tokens from chars misses long RAG context — Estimate says 500 tokens; reality is 5000 after grounding.
  • Platform Event volume limits — High-traffic agent saturates your 24h PE quota.
  • Ledger bucket skew — Timezone boundary resets at midnight UTC, users see it mid-afternoon locally.

Top LLM Anti-Patterns (full list in references/llm-anti-patterns.md)

  • Trusting Agentforce to rate-limit for you — it only fails loudly on hard limits.
  • Hard-coded tokens/minute without per-persona CMDT — cannot respond to traffic shifts.
  • Synchronous ledger DML per turn — blows DML limits.

Official Sources Used

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Use this skill when writing test-first, behavior-driven acceptance criteria in Given/When/Then format for a Salesforce user story. Covers happy path, edge cases, negative paths, permission boundaries, and data-state preconditions so the AC block can drive UAT scripts and Apex test design downstream. Trigger keywords: given when then, gherkin, behavior driven AC, test first acceptance criteria, scenario outline, BDD acceptance criteria. NOT for the user-story format itself (use admin/user-story-writing-for-salesforce). NOT for UAT script writing (use admin/uat-test-case-design). NOT for Apex test method generation (use agents/test-class-generator). NOT for high-level UAT planning (use admin/uat-and-acceptance-criteria). More triggers: acceptance criteria record, ac_id, req_id on a criterion, artefact under test, negative case for a rule-type requirement, no-match fall-through criterion, oracle for a Then clause, test type apex flow manual, criteria linter, check_ac_format.py, --manifest-dir.

日本語の概要は準備中です。原文の説明を表示しています。

PranavNagrecha/AwesomeSalesforceSkills192026年10月4日 更新

Task and Event objects: polymorphic WhatId/WhoId, Activity object model, ActivityHistory vs OpenActivity, activity timeline customization, bulk task creation, Einstein Activity Capture boundaries. NOT for turning on EAC or calendar sync — use admin/einstein-activity-capture-setup. NOT for Email-to-Case — use admin/case-management-setup. Covers ActivitiesSettings metadata, enableActivities, shared Task/Event custom fields and FLS, TaskStatus value sets, Shared Activities and TaskRelation/EventRelation, recurring and child activities, and partial-success bulk DML on Task.

日本語の概要は準備中です。原文の説明を表示しています。

PranavNagrecha/AwesomeSalesforceSkills192026年10月4日 更新

Design Invocable Apex actions that return deterministic, agent-friendly errors instead of surfacing raw exceptions to the LLM. NOT for authoring the action itself — @InvocableMethod schema, labels, security context — use agentforce/custom-agent-actions-apex. NOT for the Apex tests that force each error branch — use agentforce/agent-action-unit-tests.

日本語の概要は準備中です。原文の説明を表示しています。

PranavNagrecha/AwesomeSalesforceSkills192026年10月4日 更新

Use when designing how an Agentforce agent extracts structured input parameters (slots) from a user's natural-language utterance to invoke an action. Triggers: 'agent extract date from user', 'agent action argument extraction', 'agentforce slot filling', 'agent invocable input mapping', 'agent fails to fill required parameter'. NOT for action authoring (use agentforce/agent-actions) or for prompt-template variable binding (use agentforce/prompt-builder-templates).

日本語の概要は準備中です。原文の説明を表示しています。

PranavNagrecha/AwesomeSalesforceSkills192026年10月4日 更新

Apex test patterns for @InvocableMethod agent actions: per-reason-code branch coverage, bulk safety, callout mocking, deterministic assertions. NOT for testing whether the agent routes to the right topic or answers well — use agentforce/agent-testing-and-evaluation. NOT for designing the error envelope the tests assert on — use agentforce/agent-action-error-handling.

日本語の概要は準備中です。原文の説明を表示しています。

PranavNagrecha/AwesomeSalesforceSkills192026年10月4日 更新

Designing or reviewing Agentforce actions: Flow actions, Apex invocable actions, prompt-template actions, action naming, input and output contracts, confirmation requirements, and safe error behavior. Triggers: 'agent actions', 'build an agent that can look up an order', 'make the agent able to check order status', 'give the agent a capability', 'agent that can retrieve a record', 'flow action for agent', 'agent invocable action', 'action schema design'. NOT for writing the Apex class itself — use agentforce/custom-agent-actions-apex. NOT for the reason_code error envelope that stops an agent retry loop — use agentforce/agent-action-error-handling.

日本語の概要は準備中です。原文の説明を表示しています。

PranavNagrecha/AwesomeSalesforceSkills192026年10月4日 更新

PranavNagrecha のスキルをすべて見る

このスキルの問題を報告する