Skip to main content
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>'
{
  "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

authorization
string
required
Your API key for authentication.

Path Parameters

id
string
required
The run ID to analyze.

Response

analysis
object
The AI-generated analysis of the failed test run.
{
  "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"
    }
  }
}