Introduction
Building on the previous post, how can we find out how many tokens are being used in the LLM calls?
Let's run the agent again -
The integration that runs the agent is -I check out the activity stream - I search the log for "token" - the LLM Conversation payload is -Think
I need to retrieve the integration flow instances for two integrations given:
1. UPDATE_ORDER in project AA_ANOMALY_DETECTION
2. CREATE_ORDER in project AA_ANOMALY_DETECTION
By invoking the function RETRIEVE_INTEGRATIO_INSTANCES twice with each projectId and integrationId,
I can get the flow instances and their execution times. From the durations,
I can analyze for anomalies where flows took longer than usual.
Action
I will call the function RETRIEVE_INTEGRATIO_INSTANCES for both integrations in parallel as they are independent of each other.
"tool_calls":[{\"type\":\"function\",\"function\":{\"name\":\"RETRIEVE_INTEGRATIO_INSTANCES\",
\"arguments\":{\"projectId\":\"AA_ANOMALY_DETECTION\",
\"integrationId\":\"UPDATE_ORDER\"}},\"id\":\"call_julG58UCC7IP3cy4IhDVijpB\"},{\"type\":\"function\",\"function\":
{\"name\":\"RETRIEVE_INTEGRATIO_INSTANCES\",\"arguments\":{\"projectId\":\"AA_ANOMALY_DETECTION\",\"integrationId\":
\"CREATE_ORDER\"}},\"id\":\"call_yrTHmJSPC9vLVb9gCY8EKXqK\"}]}",
I need to retrieve the integration flow instances for two integrations given:
1. UPDATE_ORDER in project AA_ANOMALY_DETECTION
2. CREATE_ORDER in project AA_ANOMALY_DETECTION
By invoking the function RETRIEVE_INTEGRATIO_INSTANCES twice with each projectId and integrationId,
I can get the flow instances and their execution times. From the durations,
I can analyze for anomalies where flows took longer than usual.
Action
I will call the function RETRIEVE_INTEGRATIO_INSTANCES for both integrations in parallel as they are independent of each other.
"tool_calls":[{\"type\":\"function\",\"function\":{\"name\":\"RETRIEVE_INTEGRATIO_INSTANCES\",
\"arguments\":{\"projectId\":\"AA_ANOMALY_DETECTION\",
\"integrationId\":\"UPDATE_ORDER\"}},\"id\":\"call_julG58UCC7IP3cy4IhDVijpB\"},{\"type\":\"function\",\"function\":
{\"name\":\"RETRIEVE_INTEGRATIO_INSTANCES\",\"arguments\":{\"projectId\":\"AA_ANOMALY_DETECTION\",\"integrationId\":
\"CREATE_ORDER\"}},\"id\":\"call_yrTHmJSPC9vLVb9gCY8EKXqK\"}]}",
The next occurrence of llmConvTotalTokens -
Note also the logging of the model name - gpt-4.1-mini-2025-04-14.Here the payload is -
Think
I have retrieved the integration flow execution instances for the two integrations,
UPDATE_ORDER and CREATE_ORDER, both in the project AA_ANOMALY_DETECTION.
Each returned data contains multiple flow instances with their respective durations.
To detect anomalies, I will analyze and compare the flow durations to identify any that
take significantly longer than the others.
Observe
For UPDATE_ORDER, the durations are 30016ms, 55ms, and 56ms.
The duration 30016ms stands out as an anomaly due to being much larger than the others.
For CREATE_ORDER, the durations are 20013ms, 11ms, 56ms, and 58ms.
The duration 20013ms is clearly an anomaly here due to being much higher than the other execution times.
Act
I will now prepare the results in tables for each integration,
highlighting the anomalies and outputting the details as requested.
For the integrations in the project AA_ANOMALY_DETECTION,
the anomaly detection resultsin execution times are as follows:
Integration: UPDATE_ORDER
projectId | integrationId | totalFlows | anomaly_creationDate | anomaly_instanceId | anomaly_duration |
|--------------------|----------------|------------|----------------------------|---------------------|------------------|
| AA_ANOMALY_DETECTION | UPDATE_ORDER | 3 | 2026-06-11T06:06:15.927+0000 | p_cv2WVbEfGFktn245kveg | 30016 ms |
Integration: CREATE_ORDER\\n| projectId | integrationId | totalFlows | anomaly_creationDate | anomaly_instanceId | anomaly_duration |
--------------------|----------------|------------|----------------------------|--------------------|------------------|
| AA_ANOMALY_DETECTION | CREATE_ORDER | 4 | 2026-06-11T06:05:25.694+0000 | iiXTE2VbEfGk-wer2fD-QA | 20013 ms
|The above tables show the total number of flow instances and highlight specific flow instances where
the execution duration was significantly longer than usual, indicating anomalies.
I have retrieved the integration flow execution instances for the two integrations,
UPDATE_ORDER and CREATE_ORDER, both in the project AA_ANOMALY_DETECTION.
Each returned data contains multiple flow instances with their respective durations.
To detect anomalies, I will analyze and compare the flow durations to identify any that
take significantly longer than the others.
Observe
For UPDATE_ORDER, the durations are 30016ms, 55ms, and 56ms.
The duration 30016ms stands out as an anomaly due to being much larger than the others.
For CREATE_ORDER, the durations are 20013ms, 11ms, 56ms, and 58ms.
The duration 20013ms is clearly an anomaly here due to being much higher than the other execution times.
Act
I will now prepare the results in tables for each integration,
highlighting the anomalies and outputting the details as requested.
For the integrations in the project AA_ANOMALY_DETECTION,
the anomaly detection resultsin execution times are as follows:
Integration: UPDATE_ORDER
projectId | integrationId | totalFlows | anomaly_creationDate | anomaly_instanceId | anomaly_duration |
|--------------------|----------------|------------|----------------------------|---------------------|------------------|
| AA_ANOMALY_DETECTION | UPDATE_ORDER | 3 | 2026-06-11T06:06:15.927+0000 | p_cv2WVbEfGFktn245kveg | 30016 ms |
Integration: CREATE_ORDER\\n| projectId | integrationId | totalFlows | anomaly_creationDate | anomaly_instanceId | anomaly_duration |
--------------------|----------------|------------|----------------------------|--------------------|------------------|
| AA_ANOMALY_DETECTION | CREATE_ORDER | 4 | 2026-06-11T06:05:25.694+0000 | iiXTE2VbEfGk-wer2fD-QA | 20013 ms
|The above tables show the total number of flow instances and highlight specific flow instances where
the execution duration was significantly longer than usual, indicating anomalies.
The token count is equal to input prompt + model output response.
To validate all of this, let's run the agent again, setting the trace on ReAct Pattern Intg to debug -
So the total cost in tokens for this agent run is 4812 + 781 = 5594.
No comments:
Post a Comment