Tracking Agent AI Costs
(beta)
As your AI agents scale, monitoring their operational costs is critical for budgeting and optimization. The Report View in Foldspace allows you to track spending not just at a high level, but down to the specific function or action being performed.
Why use this report?
- Cost Attribution: Identify exactly which agent capabilities (e.g., "Search Knowledge" vs. "Create Agent") are driving your bill.
- Trend Analysis: Spot daily spikes in spending to correlate with new feature launches or traffic surges.
- Budgeting: Use historical data to forecast future LLM resource requirements.
Step-by-Step Configuration
1. Create a new Event Explorer report and select the Activity Source
In the Events or Metrics section (sidebar):
- Select the event Action Called. This event triggers every time your agent performs a distinct task.
2. Configure the Cost Metric
By default, reports count how many times an event happened. To track cost, you must change the aggregation:
- Click the dropdown label that says Total Events or Unique (under the event name).
- Select Aggregate Property.
- Choose the property Estimated cost.
- Select Sum as the method.
- Result: The metric label should now read:
User Sum of Estimated cost.
3. Breakdown by Action (Crucial Step)
To see the colorful segmentation shown in the chart (where each color represents a different function):
- Go to the Breakdown section in the sidebar.
- Select Action key.
- Why this matters: Without this, you will only see a single total bar. Adding this breakdown separates the cost for
search_knowledge,open_support_ticket, etc.
4. Visualization Settings
- Chart Type: Set to Stacked Bar (top right dropdown). This is best for visualizing how different actions contribute to the total daily cost.
- Time Range: Select 7D or 30D to see recent trends.
Interpreting the Data
The Stacked Bar Chart
The visual graph shows your total daily spend, segmented by action type.
- Height of Bar: Represents the total cost for that day.
- Colored Segments: Show the portion of cost attributed to specific actions.
- Example: In the screenshot, the large blue segment on Jan 14 indicates that
search_knowledgewas the primary cost driver for that day.
The Data Table
Below the chart, the table provides the exact financial impact of each action.
- Total: The cumulative cost of that action over the selected timeframe.
- Average: The typical daily cost.
- Daily Breakdown: The exact spend per day (e.g.,
search_knowledgecost $0.037 on Jan 12).
Pro Tip: If you notice a specific action (like
search_knowledge) becoming too expensive, you may need to optimize the prompt tokens or cache the results for that specific tool.
Updated about 2 months ago