Last week I was engaged in a conversation in the Salesforce community that boiled down to: “How do you measure and save tokens in your Agentforce implementation?” I had thought that the answer was obvious. It wasn’t, and here’s why.
Agentforce billing is genuinely complex. Multiple pricing models exist, and how credits get metered depends on which one you’re on and which feature triggered it. Salesforce documents it here; read it before assuming you know how your org is billed.
Salesforce offers real-time tracking, and the consumption cardsin the account section show precisely where the credits go, broken down by tag; for example, by environment, feature, or individual agent. I tag every new agent and keep an eye on them.
The number that makes it click
For each action, you are given an allowance of 10,000 tokens, at a cost of 20 Flex Credits (~$0.10). This quota includes all the elements within the action such as the system instructions, the user input, the prompt template text, the retrieved grounding data, and the response. If you go over by just one token, the charge doubles; 10,001 tokens will cost $0.20 rather than $0.10. If you exceed 20,000 tokens, then you will be charged for three actions. For more details, see billable usage types.
Save tokens from the start
- Optimize grounding data. Avoid injecting knowledge articles, PDFs, or raw record snapshots into a prompt template. Use a retriever with prefilters so the agent pulls only the relevant chunk, and keep knowledge articles condensed. For multi-record grounding, run a prompt flow that returns a minimal JSON payload instead of stitching everything into the prompt.
- Build specialized agents. An agent covering ten use cases reasons longer and calls more actions just to figure out intent. Narrow agents converge faster. If you’re adding a fifteenth topic to an existing agent, split it into two.
- Write direct, minimal prompts. Every extra sentence in a template gets reprocessed on every invocation. Cut unused context variables and jargon. While it sounds simple, this is the most overlooked optimization opportunity.
- Watch the input-to-output ratio. Output tokens cost more than input tokens. Structured, concise responses beat long unstructured prose.
- Test in sandbox first. Sandbox usage is discounted; the cheapest place to catch a misbehaving agent before it’s live.
- Track Agentic Work Units (AWU), not just tokens. AWU is Salesforce’s metric for actual work completed, not raw token volume. High tokens with a low AWU count signals something’s off before it hits an invoice.
Two stories from practice
The manager agent that should have been a dashboard
Setup: I shipped an agent to help managers surface priorities in their workday. Within weeks, token consumption spiked – odd, since only a handful of managers used it.
Discovery: I pulled the logs. They asked the same question repeatedly, multiple times a day. The agent answered correctly every time, but rebuilt the same analysis from scratch each time.
Fix: I retrained the agent to return a link to an existing dashboard for that question, with a note that it’ll flag any changes. Same outcome, a fraction of the cost.
Takeaway: where a question is repetitive, and the underlying data does not change from minute to minute, it should be included in a dashboard together with a notification and not in a conversational agent.
The agent that outgrew its intent
Setup: We built a broad agent with access to Salesforce MCP functionality, meant to help developers understand org configuration when documentation or tribal knowledge was missing.
Discovery: In practice, people used it to generate full documentation or draft internal articles. Each of those requests was far heavier and more expensive than what the agent was scoped for.
Root cause: nobody did anything wrong; the agent just allowed it.
Takeaway: even a technically sophisticated, trusted audience needs real guardrails on intent. Scope the agent tightly, and build in friction for anything outside that scope.
Where this leaves me
None of this is a one-time setup. Use consumption cards, tagging, sandbox testing, and tight agent scope to build right and catch rogue agents. The tools to catch waste already exist inside Salesforce. The job is making sure someone’s actually watching the logs, not just the invoice.