Tool Call aggregate_dataview
Computes a single number - sum, count, average, minimum or maximum - over the result of a predefined DataView, e.g. “the billable hours of the current mandate in the current reporting period.”
The DataView already defines which cases are selected, so the agent does not have to describe any search criteria. A reporting step can be driven by a prompt against an existing DataView, and the selection is modeled once instead of being repeated in every prompt.
aggregate_dataview is a powerful tool: it selects many cases, calculates, and writes results into the current case. This page explains what it does, so you can predict its behavior and side effects when you use it in a prompt.
See Tool Calls for the general concept.
The Principle: The LLM Never Computes
LLMs are unreliable at exact arithmetic over many records. Sending the raw cases to the LLM just to have it add up a field would also be slow, expensive and not acceptable for figures that feed billing or reporting. Therefore:
- The agent only decides which aggregation to run: which DataView, which filter, which field, which function.
- The selection, filtering and calculation run on the server, in a deterministic way.
- The values of individual cases are never returned to the agent. It only receives the computed number and some bookkeeping information.
- Everything that builds on the number - ratios, deviations, comparisons with a budget (e.g. “hours booked vs. hours contracted”) - is not a job for the agent either. Do it in a script step of the BPMN model after the aggregation, not in the prompt.
When to use
| If… | Use |
|---|---|
| a DataView already selects the cases you want to calculate over | aggregate_dataview |
| the cases are selected by field values you give in the prompt | aggregate_workitems |
How the Cases Are Selected
aggregate_dataview only takes the name of a DataView. The stored query of the DataView is executed for the current case. If the DataView depends on the current case - for example it selects only the entries of the mandate and reporting period of the current case - this binding is already part of the DataView definition. It happens automatically, and neither you nor the agent have to pass anything for it. There is no criteria argument and no <item>itemname</item> syntax here.
Three things are worth knowing:
An unknown DataView name is an error. The tool call fails with a clear error message instead of returning an empty result. A misspelled or outdated name in a prompt can therefore never end up as a silently wrong figure of 0 - the failure is visible, and you can fix the model. (Some forms in the UI treat a missing DataView as “no data”. This tool deliberately does not.)
The sort order of the DataView is ignored. A sum, count or average does not depend on the order of the cases, so sorting would only cost time.
The name is a fixed value. The DataView name is chosen by you when you write the prompt. It cannot be taken from a field of the current case.
Arguments
| Argument | Required | Description |
|---|---|---|
dataView |
yes | Name of the DataView, exactly as configured on the platform |
filter |
yes | Additional condition, or an empty value if not needed. See The filter Argument |
function |
yes | One of sum, count, avg, min, max |
aggregateField |
yes* | The numeric field to aggregate, e.g. service.hours. *Not needed for count |
targetField |
no | Field of the current case to write the result into. If omitted, the result is only returned to the agent, not saved |
matchIdsField |
no | Field of the current case to write the list of all matched cases into, for traceability. Independent of targetField |
The filter Argument
The DataView selects the cases. filter narrows that selection further, for conditions the DataView does not already contain - most commonly a business field such as “billable”. It is applied to every case of the DataView result, after the DataView query has run. A case that does not match the filter is left out completely.
The format is a list of (fieldname:pattern) blocks, e.g.
(service.billable:true)
See Selecting Workitems. A filter is a fixed text that you write in the prompt. It cannot contain <item>itemname</item>.
filter is required - even if it is empty
filter has to be present in every call, even if you don't need it. An empty value means “no filter - take everything the DataView returns”.
This is intentional and based on a test result: with a locally hosted model (14B, quantized, temperature: 0) an optional filter was reproducibly forgotten in one of two almost identical calls in the same answer. This did not happen randomly, but consistently for that shape of call, across several test runs. Once the field was defined as required, the problem disappeared. The working theory: the tool-call generator of llama.cpp-based inference enforces required fields structurally, while optional fields depend on the sampling of the model - and sampling is less reliable for the one field that differs between two similar calls.
What this means for your prompt:
- Always include the
filterkey in your example, even when it is empty. - When you need several similar calls (e.g. billable and non-billable hours), write each call as a complete, copy-ready set of parameters. Don't describe only what differs between them.
What the Tool Changes - Side Effects
Besides returning the result to the agent, the tool writes into the current case, but only if you ask it to:
| Field | What is written | Written when |
|---|---|---|
targetField |
The computed number | targetField is given |
matchIdsField |
The list of the IDs of all matched cases (max. 500) | matchIdsField is given |
Nothing else is changed. The matched cases themselves are only read.
Both fields are overwritten on every call - never appended. An aggregation is a snapshot of a report that can be run again. A list that grows with every run would silently become wrong. For you this means:
- Running the agent again always produces the current state.
- Every call needs its own target fields. If two calls (e.g. billable and non-billable) write into the same field, the second one overwrites the first.
- If you want to keep a result as history, copy it to another field in a BPMN script step before the next run.
The list of matched cases is capped at 500 entries. The calculation itself is not: the number is always computed over all cases. If the list was cut off, the result says truncated: true.
Cases with a missing or non-numeric value in aggregateField are skipped. The server log shows a warning. One bad record never makes the whole calculation fail. If your data may contain such records, check the log when a figure looks too low.
What the Agent Gets Back
The agent receives the result and bookkeeping information, never the values of individual cases:
{
"function": "sum",
"dataView": "mandatsrapportierung-by-period",
"matchCount": 5,
"value": 23.0,
"aggregateField": "service.hours",
"targetField": "billing.hours.billed",
"matchIdsField": "billing.hours.billed_ids",
"matchIdsStored": 5,
"truncated": false
}
| Field | Meaning |
|---|---|
value |
The computed number. For avg rounded to 4 decimal places |
matchCount |
Number of cases that were included |
matchIdsStored |
Number of IDs written to matchIdsField |
truncated |
true if the ID list was cut off at 500 entries |
Your prompt can use these fields, e.g. “state the total and how many bookings were included (matchCount)”.
Large Data Sets
The result is always exact, regardless of the number of cases. The duration is different:
- A plain count without
filterand withoutmatchIdsFieldis answered directly by the search index. This is very fast, even for large sets. - As soon as a
filteror amatchIdsFieldis used, every case has to be loaded and checked. For large sets this takes longer.
If a figure only has to be a count, don't add a matchIdsField without a reason.
Prompt Example
Aggregate billable and non-billable service hours for the current mandate and period.
The DataView 'mandatsrapportierung-by-period' selects service entries for the
current mandate and reporting period.
Execute two tool calls, each exactly once, in this order.
1. Billable hours of the reporting period
- dataView: "mandatsrapportierung-by-period"
- filter: "(service.billable:ja)"
- aggregateField: "service.hours"
- function: "sum"
- targetField: "billing.hours.billed"
- matchIdsField: "billing.hours.billed_ids"
2. Non-billable hours of the reporting period
- dataView: "mandatsrapportierung-by-period"
- filter: "(service.billable:nein)"
- aggregateField: "service.hours"
- function: "sum"
- targetField: "billing.hours.notbilled"
- matchIdsField: "billing.hours.notbilled_ids"
Checklist for the Prompt
- Name the DataView exactly as configured on the platform. The agent cannot discover or check DataView names and must never guess one.
- Say what the DataView already selects (mandate, period, status). This makes the prompt understandable for the next modeler, and it explains why there is no
criteria. - Spell out the
filtercompletely, with the instruction to pass it through unchanged - and always include the key, even when empty. - One complete parameter set per call.
- Separate target fields for every call.
- Decide whether the result is stored and in which field.
- Say what the agent must not do: no own calculations, no ratios, no budget comparison.
- Plan the follow-up: ratios and deviations belong to a script step of the BPMN model after the aggregation.
Known Limits
- The finding about the required
filteris based on tests with one locally hosted model family. It has not been tested with other model providers. Keepingfilterrequired is the safe choice: an empty required field costs nothing when everything works. - The DataView name cannot be set dynamically from a field of the case. It is a fixed value of the prompt.
- Rounding of
avg(4 decimal places, half up) is the same as inaggregate_workitems. The two tools do not share code, so a difference is theoretically possible in future versions.