Analyze Failed Run
curl --request POST \
--url https://api.bland.ai/v1/agent-testing/runs/{id}/analyze \
--header 'authorization: <authorization>'import requests
url = "https://api.bland.ai/v1/agent-testing/runs/{id}/analyze"
headers = {"authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {authorization: '<authorization>'}};
fetch('https://api.bland.ai/v1/agent-testing/runs/{id}/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.bland.ai/v1/agent-testing/runs/{id}/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.bland.ai/v1/agent-testing/runs/{id}/analyze"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.bland.ai/v1/agent-testing/runs/{id}/analyze")
.header("authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v1/agent-testing/runs/{id}/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"analysis": {
"root_cause": "The agent failed to transfer the caller to a live representative when the caller explicitly requested to speak with a manager. The 'Escalation Handler' node's prompt does not include instructions for handling direct manager requests, causing the agent to loop back to the main menu instead.",
"suggestions": [
{
"type": "prompt_change",
"target_node_id": "node_8f3a2b1c",
"target_node_name": "Escalation Handler",
"description": "The escalation node's prompt does not account for explicit manager requests. Adding a condition to detect phrases like 'speak to a manager' or 'talk to someone' would allow the agent to route correctly.",
"suggested_change": "Add the following to the node prompt: 'If the caller asks to speak with a manager, supervisor, or live person, immediately transfer them to the manager queue without further qualification.'",
"confidence": 0.92
},
{
"type": "flow_change",
"target_node_id": "node_4d7e9f0a",
"target_node_name": "Main Menu",
"description": "The Main Menu node has a fallback edge that loops back to itself when no intent is matched. This creates an infinite loop when the escalation path fails to trigger.",
"suggested_change": "Add a new edge from 'Main Menu' to 'Escalation Handler' that triggers when the caller's intent is classified as 'escalation' or 'transfer_request'.",
"confidence": 0.78
}
],
"node_id_to_name": {
"node_8f3a2b1c": "Escalation Handler",
"node_4d7e9f0a": "Main Menu",
"node_1a2b3c4d": "Greeting",
"node_5e6f7a8b": "Transfer to Manager"
}
}
}
Agent Testing
Analyze Failed Run
Run AI-powered analysis on a failed test run to get root cause and fix suggestions.
POST
/
v1
/
agent-testing
/
runs
/
{id}
/
analyze
Analyze Failed Run
curl --request POST \
--url https://api.bland.ai/v1/agent-testing/runs/{id}/analyze \
--header 'authorization: <authorization>'import requests
url = "https://api.bland.ai/v1/agent-testing/runs/{id}/analyze"
headers = {"authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {authorization: '<authorization>'}};
fetch('https://api.bland.ai/v1/agent-testing/runs/{id}/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.bland.ai/v1/agent-testing/runs/{id}/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.bland.ai/v1/agent-testing/runs/{id}/analyze"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.bland.ai/v1/agent-testing/runs/{id}/analyze")
.header("authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v1/agent-testing/runs/{id}/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"analysis": {
"root_cause": "The agent failed to transfer the caller to a live representative when the caller explicitly requested to speak with a manager. The 'Escalation Handler' node's prompt does not include instructions for handling direct manager requests, causing the agent to loop back to the main menu instead.",
"suggestions": [
{
"type": "prompt_change",
"target_node_id": "node_8f3a2b1c",
"target_node_name": "Escalation Handler",
"description": "The escalation node's prompt does not account for explicit manager requests. Adding a condition to detect phrases like 'speak to a manager' or 'talk to someone' would allow the agent to route correctly.",
"suggested_change": "Add the following to the node prompt: 'If the caller asks to speak with a manager, supervisor, or live person, immediately transfer them to the manager queue without further qualification.'",
"confidence": 0.92
},
{
"type": "flow_change",
"target_node_id": "node_4d7e9f0a",
"target_node_name": "Main Menu",
"description": "The Main Menu node has a fallback edge that loops back to itself when no intent is matched. This creates an infinite loop when the escalation path fails to trigger.",
"suggested_change": "Add a new edge from 'Main Menu' to 'Escalation Handler' that triggers when the caller's intent is classified as 'escalation' or 'transfer_request'.",
"confidence": 0.78
}
],
"node_id_to_name": {
"node_8f3a2b1c": "Escalation Handler",
"node_4d7e9f0a": "Main Menu",
"node_1a2b3c4d": "Greeting",
"node_5e6f7a8b": "Transfer to Manager"
}
}
}
Headers
string
required
Your API key for authentication.
Path Parameters
string
required
The run ID to analyze.
Response
object
The AI-generated analysis of the failed test run.
Show analysis object
Show analysis object
string
Description of why the test failed.
array
An array of suggested fixes for the failure.
Show suggestion object
Show suggestion object
string
The type of suggested change. One of:
prompt_change, node_config, flow_change, tone_improvement.string
The ID of the node the suggestion applies to.
string
The display name of the node the suggestion applies to.
string
A human-readable description of the issue and what should change.
string
The specific change to make (e.g., updated prompt text or configuration value).
number
Confidence score for this suggestion, from 0 to 1.
object
A map of node IDs to their display names, covering all nodes referenced in the analysis.
{
"analysis": {
"root_cause": "The agent failed to transfer the caller to a live representative when the caller explicitly requested to speak with a manager. The 'Escalation Handler' node's prompt does not include instructions for handling direct manager requests, causing the agent to loop back to the main menu instead.",
"suggestions": [
{
"type": "prompt_change",
"target_node_id": "node_8f3a2b1c",
"target_node_name": "Escalation Handler",
"description": "The escalation node's prompt does not account for explicit manager requests. Adding a condition to detect phrases like 'speak to a manager' or 'talk to someone' would allow the agent to route correctly.",
"suggested_change": "Add the following to the node prompt: 'If the caller asks to speak with a manager, supervisor, or live person, immediately transfer them to the manager queue without further qualification.'",
"confidence": 0.92
},
{
"type": "flow_change",
"target_node_id": "node_4d7e9f0a",
"target_node_name": "Main Menu",
"description": "The Main Menu node has a fallback edge that loops back to itself when no intent is matched. This creates an infinite loop when the escalation path fails to trigger.",
"suggested_change": "Add a new edge from 'Main Menu' to 'Escalation Handler' that triggers when the caller's intent is classified as 'escalation' or 'transfer_request'.",
"confidence": 0.78
}
],
"node_id_to_name": {
"node_8f3a2b1c": "Escalation Handler",
"node_4d7e9f0a": "Main Menu",
"node_1a2b3c4d": "Greeting",
"node_5e6f7a8b": "Transfer to Manager"
}
}
}
Docs for agents: llms.txt
Was this page helpful?
⌘I