Class AgentCostByModelQueryResultMapper

java.lang.Object
com.flowable.platform.service.dashboard.resultmapper.extractor.AgentCostByModelQueryResultMapper
All Implemented Interfaces:
DashboardComponentQueryResultMapper

public class AgentCostByModelQueryResultMapper extends Object implements DashboardComponentQueryResultMapper
Computes the total cost per LLM model by combining the input/output/cached token sums from the _flowable_AgentInvocationTokensByModelByTypeQuery query result with the model prices stored in the configuration store for the tenant.

The query produces three groupByNestedFieldFilteredWithSumField aggregations (inputTokens, outputTokens, cachedTokens). Each is structured as /aggregations/{aggName}/{aggName}_filtered/{aggName}_inner/buckets, where the bucket key is the model name and the summed token count lives at {aggName}_sum/value.

Cost is tokens / 1_000_000 * price per token type, using the longest model-prefix match from the effective price list. Models with no matching price are skipped.