How to Test AI Models & Agents for Reliability


by Adam Sandman on

How to Test AI Models: Why Traditional QA Isn't Enough

As AI agents become more embedded in workflows, do you actually trust them to perform work properly, escalate roadblocks to the right human, access real business data, make decisions, and resist exploitation attempts like prompt injections? When it came to traditional software, the QA process revolved around determining whether the system produced the expected result from a known input under a defined system state. With AI, the question and scope of QA needs to broaden — can you demonstrate that it will behave acceptably across the range of users, data, conversations, attacks, business situations, and other factors it may encounter?

If you want to take a step back and learn about the benefits of agentic AI before diving deeper, click here.

AI agents aren’t simple models. They’re complex systems made up of prompts, model configurations, retrieval sources, memory, guardrails, tools, permissions, workflow logic, and human approval gates. Enterprise AI requires assurance, not just testing in the narrow sense. Assurance combines behavioral evaluation, security testing, risk management, human oversight, traceability, and continuous reassessment. Traditional software testing frameworks weren’t built with this structure in mind, so new testing and QA methods are being developed to evaluate AI systems more effectively. Today, we’ll dive deeper into how testing is evolving to adapt to AI and what it means for software vendors who are building AI-powered capabilities into their platforms.

Why AI Breaks Traditional Testing

You may have come across this term before, but the primary reason that traditional (or even automated) testing isn’t effective for AI systems is because of non-determinism. Historically, software testing assumes three things:

  • Behavior is largely repeatable
  • Expected results can be defined in advance
  • Meaningful changes usually follow a code or config update

Non-determinism means that the same inputs can result in different outputs (hence, you can’t determine the output ahead of time). Consequently, AI challenges or complicates the assumptions we laid out above for a handful of reasons:

  • The same input can produce different results: Generative models behave probabilistically, so the same request will often yield different wording, conclusions, tool choices, or workflow paths. Therefore, a single test proves very little — teams need to measure how often the agent succeeds, not just whether it succeeds once.
  • Correctness is often semantic: Conventional test automation works well when the expected result is an exact-match output, like a status code, database value, or UI state. As mentioned above, AI responses can be phrased differently but may still be correct (or, conversely, sound convincing while being incomplete, unsafe, or inaccurate).
  • Failures emerge across complete workflows: Your AI agent may choose the right tool but use the wrong parameters, complete a task while bypassing a required approval, or retrieve the correct information but summarize it incorrectly. Enterprise QA needs to evaluate the full trajectory, not just the initial response.
  • Behavior can change without a code release: Model updates, prompt edits, retrieval-index changes, tool modifications, guardrail adjustments, and a variety of other factors can significantly alter how an agent behaves. This is why continuous behavioral evaluation is critical to maintaining system reliability.

Click here to learn how to build AI agents for businesses.

Consequences of Unreliable Agents in Business Systems

When it comes to vibe coding your own personal app, an incorrect AI response might be a simple inconvenience. However, AI is increasingly being used to accelerate critical workflows in healthcare, finance, government agencies, aviation, and more. In these systems, incorrect or unsafe AI responses can have much higher consequences.

  • Financial and legal exposure: An agent might invent/hallucinate a discount, misstate a refund policy, or make an unsupported commitment that you are responsible for. For example, Air Canada was found liable after its chatbot provided inaccurate information about their bereavement fare policy.
  • Security and privacy incidents: Agents that connect to enterprise data and tools can accidentally expose customer records, credentials, internal documents, intellectual property, or other regulated information. Prompt injection and excessive permissions can also enable agents to perform unauthorized actions.
  • Operational disruption: The wrong tool call can end up creating duplicate transactions, modifying the wrong records, sending an incorrect communication, or leaving a workflow partially completed. When multiple agents and systems are connected, this can cascade and propagate through several applications.
  • Compliance and audit failures: Regulated organizations typically need to demonstrate what an AI system is expected to do, how it was tested, what risks were identified, and who approved its release. Informal prompt experiments and screenshots are not defensible evidence, so teams need documented test results.
  • Loss of trust and adoption: AI errors can be difficult to identify because they are usually delivered confidently. If your customers or employees stop trusting an agent, they begin second-guessing every answer, looking for workarounds, or leaving it entirely, draining more time and resources on something that no one uses.

Common Causes of Agent Instability

We’ve talked about some of the most important potential consequences of AI errors and unreliability, but what actually causes this instability? There are a wide range of factors that can erode the reliability and effectiveness of your AI models, many of which can be difficult to test for with conventional software development tools:

  • Ambiguous or conflicting instructions: Agents take in instructions from system prompts, users, retrieved content, tool descriptions, policies, and conversation history. If these conflict (or are too vague), behavior may change and deprioritize certain policy boundaries or objectives.
  • Narrow or unrealistic test data: AI’s “intelligence” is based on its training data and context. Small collections of carefully written prompts don’t represent real users who might misspell words, leave out information, combine requests, and more. Thankfully, Rapise can generate synthetic data sets that mimic real-world data without the restrictions of sample size or privacy exposure.
  • Prompt injection and goal hijacking: Malicious instructions can come from a user or even from a document that your AI ingests. These attacks may redirect the agent, extract information, manipulate memory, or misuse tools. Extensive probing for prompt injection vulnerabilities, boundary violations, and more is critical for stable AI.
  • Multi-turn context and memory errors: As conversations get longer, agents might forget earlier constraints, combine information from different users, or retain malicious instructions. These are difficult to test for because they only appear after extensive conversations or delayed follow-up actions.
  • Weak retrieval context: If retrieval systems return outdated, incomplete, irrelevant, or contradictory information, agents may produce a confident answer that’s grounded in the wrong source. Rapise and SureWire help validate retrieval APIs, access rules, missing context handling, and more so AI doesn’t invent an answer.
  • Excessive permissions: When too many unnecessary tools and options are available, it increases the likelihood that your agent will choose the wrong one (and the more autonomy it has, the greater the impact of a mistake). SureWire checks tool-use behavior and boundary compliance over time, not just in one test session.
  • Weak acceptance criteria: Statements like “the answer looked good” or “we couldn’t make it fail” aren’t measurable release criteria. Enterprise AI needs to have defined objectives, representative scenarios, severity thresholds, and repeatable metrics, such as the comprehensive reporting that SureWire provides.

AI Agent Testing Framework: What Does “Good” QA Look Like?

As we’ve reiterated so far, good AI QA should do more than simply confirm whether an agent generates an acceptable response once or twice. Just as AI systems respond probabilistically, testing them also needs to take a statistical approach that measures accuracy, reliability, and behavior rates rather than binary pass/fail checks. Below, we’ll outline some of the most important best practices for testing your AI tools, and how modern platforms can support those practices and methods.

1. Define “good” in business and risk terms

The quality of AI is often context-dependent. In other words, an acceptable response for an internal brainstorming assistant may be unacceptable for a customer-facing agent that handles financial transactions, patient records, or regulated decisions. We recommend starting by defining:

  • The tasks the agent is authorized to perform (i.e. inclusions)
  • The behaviors and outcomes that are prohibited (i.e. exclusions)
  • The acceptable error and failure rates (i.e. performance thresholds)
  • The actions that require human approval
  • The conditions that should trigger refusal or escalation
  • The severity of different failure types

These shouldn’t be a generic model benchmark — they should directly correspond to the agent’s intended business use, affected users, legal obligations, and potential impact. For instance, SureWire makes it easy for your team to describe the specific agent and concern they want to investigate in plain English, and it then builds an assessment around that objective.

2. Assess the whole agentic system, not just the foundation model

Production behavior depends on more than just the underlying model. From prompts and retrieval sources to tool descriptions, permissions, and other agents, a multitude of factors can influence the outcome. For example, capable models may still fail due to:

  • Retrieval supplied outdated or irrelevant information
  • A tool was called with the wrong parameters
  • The agent had excessive permissions
  • Conversation memory preserved a false assumption
  • A handoff omitted important context
  • An external system returned misleading data

Because of this interconnected web of factors, teams need to assess complete workflows, including intermediate decisions, tool calls, handoffs, authorization boundaries, and downstream effects.

3. Treat results statistically rather than as one-time pass/fail

Another theme throughout this article is how variable outputs from generative AI are. This inherently makes a single pass or failure insufficient evidence of reliability. Put simply, important scenarios need to be run multiple times so that over time, QA teams can measure:

  • Success rate
  • Response and action variance
  • Frequency of severe failures
  • Performance under different conditions
  • Confidence in the observed result
  • Worst-case behavior (not just average behavior)

The consequences of skipping this aspect of AI testing frameworks can be severe — a system that succeeds nine times but exposes sensitive data on the tenth should not receive the same approval as a system that succeeds consistently.

4. Build representative and continually expanding test data

Testing results are only as useful as the test data. A small collection of ideal prompts will lack the ambiguity, incomplete information, unusual phrasing, and system conditions that the tool will experience in production. We recommend including these characteristics and scenarios in your test data:

  • Common user requests and workflows
  • Different personas, roles, and permission levels
  • Misspellings, shorthand, and industry terminology
  • Incomplete and contradictory requests
  • Multiple languages and locales
  • Edge cases and boundary conditions
  • Historical defects and production incidents
  • Adversarial and prohibited requests
  • Unavailable tools or incomplete source data

While this is a starting point, test data needs to evolve with user complaints, policy changes, and more. SureWire dynamically generates varied interactions from the testing concern, which reduces your dependence on a fixed prompt library.

5. Probe continuously for prompt injection and goal hijacking

Prompt injection attacks are some of the most common forms of malicious actions to hijack AI systems. They can come directly from users, as well as from documents, webpages, emails, or data retrieved from another system. If a prompt injection attack is successful, it can force the agent to:

  • Ignore system instructions
  • Reveal protected information
  • Bypass policy controls
  • Misuse connected tools
  • Modify memory or future behavior
  • Take actions outside the user’s intent

RAG and fine-tuning don’t fully eliminate the risk of prompt injection, so it’s imperative that testing includes direct, indirect, encoded, multi-turn, and context-based attacks. Thankfully, SureWire’s Bespoke Testing Agents dynamically probe for prompt injection, boundary violation, and goal hijacking so you can feel confident that your AI system is safe.

6. Test privacy, secrets, and data-exfiltration resistance

Enterprise agents that operate in key sectors may have access to sensitive information like customer records, internal communications, source code, employee credentials, or financial data. Modern testing for these systems needs to determine whether users (or malicious attacks) can push the AI to expose this data. Your testing scenarios might try to extract:

  • Another user’s records
  • System prompts and hidden instructions
  • Credentials, tokens, and API keys
  • Confidential documents
  • Personal or regulated information
  • Data from prior conversations
  • Information accessible via connected tools

To reiterate, thorough testing should cover both accidental disclosure during normal use as well as deliberate extraction through attacks like prompt injection. In fact, OWASP specifically identifies sensitive information disclosure as a core risk that can be caused by weak access controls, prompt exploitation, and inappropriate exposure of model or app data.

7. Evaluate factuality, grounding, uncertainty, and abstention

As we’ve seen with LLMs (especially earlier models), just because a response is fluent and confident doesn’t mean it’s accurate. The stakes are even higher in business environments, where agents need to properly use approved information — and recognize when the available evidence is insufficient. Your testing tools for AI systems should be able to assess whether the agent:

  • Produces factually supported answers
  • Uses the correct source or business record
  • Represents retrieved information accurately
  • Distinguishes facts from assumptions
  • Identifies conflicting evidence
  • Requests missing information
  • Appropriately expresses uncertainty
  • Abstains or escalates rather than inventing an answer

When performing this type of testing, we recommend comparing AI responses against authoritative records when possible. Thankfully, SureWire can do this for you, assessing responses for hallucinations, overconfidence, and inappropriate (or unexpected) behavior.

8. Verify policy compliance, safe refusal, and escalation

Policies and escalation paths are crucial for safe and reliable AI systems. Even when users request exceptions (or try to manipulate the tool), agents need to stick to their business rules. Your QA team should focus on analyzing whether the agent consistently applies policies across different wordings, users, and conversational contexts. This might include:

  • Requests outside the agent’s authority
  • Regulated or high-risk advice
  • Attempts to bypass authentication
  • Prohibited content or actions
  • Requests requiring managerial approval
  • Situations involving insufficient information
  • Conflicts between helpfulness and policy
  • Emergencies or cases requiring human intervention

Keep in mind that you’ll need to test for both under-refusal and over-refusal. An agent that completes unsafe requests creates risk, but one that rejects legitimate work can hurt usefulness and adoption.

9. Compare behavior across users, languages, and contexts

Because many of the most popular AI models are based primarily on English, response quality can vary for requests sent in another language. In other words, an agent that performs exceptionally well for one user group (e.g. non-technical users) or language (e.g. English) can still be inaccurate, less helpful, or even more likely to refuse other groups. Test for equivalent performance across:

  • Languages and regional variations
  • Technical and non-technical users
  • Different job roles and permission levels
  • New and experienced users
  • Direct and conversational phrasing
  • Short and long conversation histories
  • Different communication styles (e.g. assertive vs. passive)
  • Accessibility-related needs (e.g. screen readers)

QA teams should compare the metrics we discussed above (success rate, response variance, etc.) to ensure as consistent an experience as possible. However, note that the goal shouldn’t be identical wording — instead, it should be comparable quality and treatment. SureWire can quickly generate and evaluate variations of the same scenario, making it easier to detect inconsistent behavior that a single “default” prompt wouldn’t expose.

10. Preserve audit-ready evidence and close the feedback loop

Lastly, it’s important to remember that testing should not only evaluate the system’s capabilities and performance, but also document the process and results for stakeholders to review and use. We recommend keeping documentation of:

  • The agent, model, and prompt versions
  • Relevant policies and system configurations
  • Test objectives and acceptance criteria
  • Scenarios and test data
  • Requests, responses, and tool actions
  • Evaluation rubrics and results
  • Failure explanations and severity
  • Human review and approval decisions
  • Links to requirements, risks, and defects

This way, if something does go wrong, you have defensible evidence of what was tested and how thoroughly it was evaluated. Even in day-to-day operations, this also helps product, QA, security, compliance, and executive teams understand what was done and why it was approved or rejected. Having all of this automated also offers a potential competitive advantage because failures immediately become defects, new test cases, updated controls, or revised acceptance criteria for faster feedback and delivery loops.

Ship Reliable AI Agents & Tools With SureWire

Although we’ve spent most of this article discussing how AI agents have moved beyond traditional QA, those methods are still far from being irrelevant. Instead, think of traditional testing as incomplete for agents, rather than unimportant. Teams still need to verify that interfaces, APIs, permissions, and workflows function properly. At the same time, they also need to evaluate whether the AI side of the platform behaves consistently, follows policies, resists manipulation, and handles uncertainty appropriately.

This pushes modern teams towards a layered testing strategy:

  • Conventional software testing (e.g. Rapise) provides repeatable automation for the deterministic parts of your system.
  • Agentic testing (e.g. SureWire) addresses the less predictable behavioral layer by dynamically assessing AI systems across realistic, adversarial, and policy-driven scenarios.

When used together, this approach and toolbox enable teams to test both whether the software works as intended and whether the AI can be trusted within it. All Inflectra software is compliant with the following global regulations and certifications, so you can rest assured that your data is always protected and secure — including in strictly-regulated industries like aerospace, healthcare, and finance:

Inflectra Global Regulations Compliance

Inflectra ISO/IEC Certifications

GDPR (General Data Protection Regulation)

HIPAA (Health Insurance Portability and Accountability Act)

GAMP (Good Automated Manufacturing Practice)

DORA (Digital Operational Resilience Act)

NIST (National Institute of Standards and Technology) Center of Excellence

FMEA (Failure Mode and Effects Analysis)

FDA 21 CFR Part 11

Eudralex Volume 4 Part I & II

DO-178C (Airborne Software)

ISO 26262

ISO 13485

ISO 31000

ISO 20022

ISO 27001:2013

ISO 9001:2015

IEC 62304 (Cybersecurity for Industrial Automation and Control Systems)

IEC 62443 (Medical Device Software)


About the Author

Adam Sandman

Adam Sandman is a visionary entrepreneur and a respected thought leader in the enterprise software industry, currently serving as the CEO of Inflectra. He spearheads Inflectra’s suite of ALM and software testing solutions, from test automation (Rapise) to enterprise program management (SpiraPlan). Adam has dedicated his career to revolutionizing how businesses approach software development, testing, and lifecycle management.

Spira Helps You Deliver Quality Software, Faster and with Lower Risk.

Get Started with Spira for Free

And if you have any questions, please email or call us at +1 (202) 558-6885