How to Control AI Agent Costs in Slack Workflows

Set the budget per run, not per month, and make the agent reserve cost before each model call, so a run can still be stopped while stopping is possible. Count a run as finished only when its Slack message was delivered, so a failed post or a duplicate delivery cannot hide inside a successful generation, and never let a missing price count as zero. If you came for what Slack's own AI costs, that is a plan question and it is answered first below. The rest is for agents you run yourself.
A monthly token total says that money was spent. It does not say whether the workflow finished, which branch consumed the budget, or why a failed delivery was billed. This runbook is for business operations platform owners who run scheduled or thread-initiated agent work in Slack.
What Slack's own AI costs
Slack's built-in AI is priced into the plan, so the control is the plan tier and not a per-run budget. On Slack's pricing page, Pro lists at $8.75 per user per month billed monthly ($7.25 billed annually) and Business+ at $18 ($15 annually), in US dollars. By plan, Pro includes conversation and thread summaries and huddle notes, Business+ adds search, recaps, translations, file summaries and workflow automation, Enterprise+ adds enterprise search, and Free has none of these. Slackbot, Slack's personal AI agent, is a trial or preview on Free and Pro, is limited to 15 messages per member per week on Business+, and has no weekly or lifetime message limit on Enterprise+.
Turning AI off does not save money: Slack says the price of your plan does not change if you turn all AI features off, although owners and admins can restrict each feature. The separate Slack AI add-on is no longer sold. So the saving lever is the plan, and a job that a bundled feature already does, such as a summary, a search or a recap, should use it, because inside the plan's limits it costs nothing extra. The ledger below is for jobs the bundled features cannot do: reading your CRM, building a report from several sources, or drafting a customer reply for approval.
Define the unit you are buying
Start with the operational outcome, not a token ceiling. For a weekly metrics workflow, the outcome might be one report posted to the correct Slack thread with every required source marked available, partial, or failed. For a support workflow, it might be one evidence-backed draft that an authorized person can approve.
A budget attached only to the model or API key cannot distinguish those outcomes. Bind each run to:
- the Slack workspace, channel, and thread;
- the requesting user and permission snapshot;
- the workflow type and version;
- the required sources and tools;
- the maximum estimated cost;
- the approval policy for exceeding that limit;
- the final generation and delivery states.
Kipwise Agent provides the product context for this contract: work continues in Slack threads, scheduled requests can use connected tools, permissions follow the requesting user where applicable, sources are cited, and sensitive actions stay explicit. A cost control should preserve the same thread and authorization boundaries.
Choose one currency for the internal ledger. Store the original provider currency and amount as well, then convert through a dated rate owned by finance. Never mix token counts, provider currency, and converted currency in one numeric field.
Reserve before you spend
Reserve estimated cost before each expensive branch, then reconcile it against actual provider usage after the branch reaches a terminal state. A post-run alert cannot prevent overspend. The workflow needs an admission check before every model call or costly tool branch: estimate the upper bound, reserve that amount against the run budget, and release the difference when actual usage arrives.
Reservation fails when an unknown estimate is treated as zero. A LiteLLM user report describes budget reservation being skipped when a request cost could not be estimated. That report applies to a specific implementation, and the rule holds anyway: an unknown estimate needs an explicit policy, because treating unknown as free defeats the budget.
Use one of three rules when estimation fails:
- Fail closed: stop the branch and tell the requester which price or usage field is missing.
- Use a conservative ceiling: reserve an admin-approved maximum for that model and operation.
- Require approval: show the missing estimate and ask an authorized owner to accept a bounded fallback limit.
Do not silently use zero. Do not launch the call and hope the monthly dashboard catches it.
A minimal ledger can use this shape:
run_id: run_01_COST_CONTROL
thread:
workspace_id: T_WORKSPACE
channel_id: C_OPERATIONS
thread_ts: "1789384100.001200"
requester_id: U_OPERATOR
workflow: weekly-search-report
currency: USD
budget:
hard_limit: 3.00
reserved: 0.84
actual: 0.61
steps:
- step_id: search_console_query
estimate: 0.00
reserved: 0.00
actual: 0.00
state: succeeded
- step_id: evidence_summary
estimate: 0.84
reserved: 0.84
actual: 0.61
state: succeeded
outcome:
generation: succeeded
delivery: pendingThis is an implementation recommendation, not a provider schema. The important fields are the reservation, actual charge, terminal state, and Slack run identity.
Keep the usage dimensions that change the bill
Track cache reads, cache writes, retries, and tool calls separately, because a single total-token field can misstate where workflow spend came from. The OpenTelemetry generative AI metrics specification defines token-usage and operation-duration measures. Use those common measures where they fit, and keep the provider-specific dimensions needed to calculate cost accurately.
Cache accounting is one example. A Langfuse issue about Anthropic cost calculation asks for separate cache-read and cache-creation token fields in OpenTelemetry generation spans, and its author reports that omitting them makes cost calculation inaccurate. Preserve those categories rather than flattening them into input tokens.
Record at least the uncached input tokens, cache write tokens, cache read tokens and output tokens; the model and the provider's price version; the attempt number and, for a retry, its reason and the original attempt; the tool call count and duration; and the reserved and actual cost for each branch. The Langfuse token and cost tracking guide explains usage ingestion, model definitions, and cost calculation. It is useful for observing spend, but your admission rule still needs a local budget decision before the next call starts.
Give tool calls their own dimensions even when the tool has no per-call charge. A tool can return a large payload that inflates the next model input, time out and trigger a retry, or fan out into several searches, and the model usage that follows belongs to the branch that caused it.
Put the guard inside the run loop
A budget checked only at the beginning misses branching. Recalculate available budget before each call using this sequence:
available = hard_limit - actual_cost - active_reservations
estimate = upper_bound(next_step)
if estimate is unknown:
apply unknown_estimate_policy()
elif estimate > available:
stop_or_request_approval()
else:
reserve(estimate)
execute(next_step)
reconcile(provider_usage)A proposal in the OpenAI Agents SDK repository asked for per-run token, request, and cost limits checked before model calls. The maintainers closed it, replying that it could not be done with SDK-side changes alone, so read it as a design argument and not as a feature. The argument is still sound: the guard belongs in the loop where the next action can still be denied.
Use both hard and soft limits. A soft limit can switch to a cheaper model, reduce optional searches, or ask the requester whether a lower-detail result is acceptable. A hard limit stops the run unless an authorized owner explicitly expands it. Never let the agent approve its own expansion. The approval record should include the old limit, new limit, reason, approving user, permission check, expiry, and payload digest, and if the workflow inputs or the requested outcome change, invalidate the approval and estimate again.
Put the expensive branches behind a feature flag as well, so an admin can cut one without a deploy when the ledger shows a spike. The Unleash docs list a kill switch as a flag type for gracefully degrading system functionality, and treat it as permanent and not as a temporary release flag, which is the right shape for turning off a web-search branch or falling back to a cheaper model. A flag does not replace the per-run budget. The budget stops a single run, and the flag stops the pattern.
Count delivery, not generation
Measure cost per delivered Slack outcome, not cost per generated answer, so failed posting and duplicate delivery cannot hide inside a successful model call. Generation and delivery are separate terminal states. A model can finish successfully while Slack posting is delayed, rejected, rate-limited, or left uncertain after a timeout. The Slack Web API rate-limit guide documents per-method and per-workspace limits, plus special limits for message posting, so design for those constraints without regenerating the answer.
Use these states:
generation: not_started | running | succeeded | partial | failed
posting: not_attempted | pending | delivered | failed | unknown
run: running | completed | partial | failed | cancelled | budget_blockedIf posting fails, retry the delivery with the same output digest and idempotency key. Do not rerun source retrieval and generation unless evidence expired or the requester changed the task. If the posting result is unknown, reconcile Slack history before another attempt.
Charge every attempt to the same logical run while keeping attempt-level records. This lets the owner see both total cost per outcome and the branch that caused it. A run with successful generation and failed posting belongs in the failed or partial outcome denominator, not the completed one.
A scheduled report, with numbers
Assume an operations lead schedules a Monday report with a $2.00 hard limit. The agent reads Search Console and Analytics, summarizes changes, and posts the result to a Slack thread.
The source reads have no model charge in this example. The summary call reserves $0.80 and reconciles to $0.54. A second call to explain an anomaly reserves $0.60 and costs $0.47. The draft is ready at $1.01 actual cost.
Slack posting times out. The workflow marks delivery unknown and checks the thread using the original idempotency key. It finds no message, retries only the posting operation, and records delivery as successful. The completed outcome costs $1.01, not the $1.40 that was reserved and not the cost of a needless second generation.
If the anomaly branch cannot identify the selected model's price, the workflow does not reserve zero. It pauses with $1.46 available and asks the authorized owner to approve a $0.75 conservative ceiling or skip the optional explanation. The owner can make a bounded decision before spend occurs.
Show a receipt in the thread
The run receipt should help the requester without exposing provider internals or sensitive content. Post a concise one in the task thread: the workflow and run ID, the outcome and delivery status, the budget limit, reserved amount and reconciled actual cost, the number of model calls, tool calls and retries, any blocked or skipped branches and approval changes, and a restricted link to detailed traces for authorized admins. Leave out prompts, customer messages, document bodies, credentials, and raw tool payloads. Cost attribution needs identifiers, usage categories, and outcomes, not a second copy of the business data.
Close every reservation
A crashed worker, cancelled run, provider timeout, or missing usage response should not leave money reserved forever or mark actual cost as zero.
- Mark unavailable actual usage as
pending_reconciliation, not zero. - Release a reservation only after the branch is confirmed unexecuted or actual usage replaces it.
- Reconcile provider usage by request ID where the provider exposes one.
- Keep one run identity across retries and worker restarts, and block duplicate external actions independently of the cost guard.
- Alert when active reservations exceed their expected lifetime.
A provider bill can arrive after the Slack workflow finishes. Run a daily or monthly reconciliation that compares internal actuals with provider totals by model, account, and period, and flag missing request IDs, unknown models, stale price definitions, currency differences, and repeated usage records. The goal is to explain the variance, not force both systems to agree by overwriting history.
Test the controls on one workflow
Use one recurring, read-only Slack workflow in a non-production channel:
- Set a low hard limit and confirm an expensive branch is blocked before execution.
- Remove a model price and confirm the unknown-estimate policy runs instead of reserving zero.
- Return cache read and cache write usage and confirm each category is priced separately.
- Force Slack posting to fail and confirm generation is not repeated, then return an unknown posting result and confirm reconciliation happens before the retry.
- Crash a worker after reservation and confirm the ledger reaches a terminal or reconciliation state.
- Compare one known provider request with the internal actual-cost record, and replay the same Slack event to confirm no duplicate model or external action occurs.
Track budget-blocked branches, unknown estimates, stale reservations, duplicate attempts, generated-but-undelivered runs, reconciliation variance, and cost per completed outcome. Pick one scheduled Slack workflow, define its completed outcome and hard limit, and implement reservation plus reconciliation before enabling additional tools or consequential writes.



-p-1080.jpg)