AI System Testing: LLM, RAG & AI Agents | Edge1S

AI System Testing: How to Test LLMs, RAG and AI Agents Before Production

A traditional application can often be tested by comparing a defined input with an expected output. AI-enabled systems are more complex. The same prompt may produce several acceptable answers, output quality depends on context and data, and RAG or agent-based solutions introduce additional layers such as retrieval, integrations, permissions and actions performed in external systems.

Interfejs systemu AI na ekranie laptopa podczas analizy i testowania rozwiązania

That is why AI testing should not stop at the question: “Did the model produce the correct answer?” A production AI system needs to be evaluated as a whole – from input data and retrieval to model behaviour, security, integrations, performance and monitoring after deployment.

Key takeaway: the quality of an AI system does not depend on the model alone. The final result is produced by an entire chain: data → retrieval → model → prompt → integrations → permissions → application → monitoring. A QA strategy should cover every layer.

In this guide, we explain why testing AI systems differs from traditional software QA, which areas should be verified before deploying an LLM, RAG solution or AI agent to production, and how to define acceptance criteria that support a go/no-go decision before release.

Why is traditional QA not enough for AI systems?

In traditional software, a large part of testing is based on predictable system behaviour. Given a particular input and set of conditions, the application is expected to produce a specific result. With generative AI components, responses may be non-deterministic – two different outputs may both be acceptable.

This changes how quality needs to be defined. Instead of checking only whether the result exactly matches an expected output, teams may need to evaluate factual correctness, completeness, adherence to context, security and behaviour across different scenarios.

Traditional applicationAI-enabled system
An input leads to an expected output.The same input may produce several acceptable outputs.
Assertion: the result either matches or does not match.Evaluation: the result may need to be assessed against several quality criteria.
Regression is primarily triggered by code changes.Regression may be caused by changes to the model, prompt, data, retrieval or integrations.
Testing focuses on the application and integrations.Testing must also cover data, model behaviour, context and retrieval.
A release stabilises application behaviour.Quality still needs to be observed after deployment.

AI QA does not replace traditional QA. APIs, UI, integrations, authentication, authorisation, performance and business processes still need to be tested. AI introduces an additional layer: evaluating the behaviour of the AI component and its dependencies on data and context.

Worth knowing: NIST uses the concept of Testing, Evaluation, Validation and Verification (TEVV) when discussing AI systems, while the AI Risk Management Framework addresses risk management across the AI lifecycle. See NIST AI RMF 1.0.

7 layers of AI system testing

Testing the model endpoint and declaring the entire solution validated is not enough. In a production environment, the model is only one component of a larger architecture.

LayerWhat do we test?Example risk
1. Data / InputQuality, completeness, formats and edge cases.The model receives incomplete or incorrect information.
2. Retrieval / RAGWhether the correct context is retrieved.The model generates a convincing answer based on the wrong document.
3. Model / OutputCorrectness, completeness, instruction following and grounding.Hallucination or unjustified confidence.
4. SecurityPrompt injection, sensitive data and attempts to bypass safeguards.A user gains access to information they should not be able to see.
5. Agents / ToolsTool selection, parameters, actions, permissions and workflows.The agent performs a technically valid but incorrect business action.
6. Non-functionalLatency, availability, scalability and cost.The system works in a demo but is too slow or expensive in production.
7. ProductionRegression, monitoring, anomalies and changes in quality.Quality deteriorates after changes to data, prompts or the model provider.

1. Data and input: are we testing what the AI actually receives?

Even a capable model can produce poor results when input data is incomplete, outdated or inconsistent. AI testing should therefore begin before the model itself.

The evaluation set should reflect not only ideal scenarios but also the type of data the system is likely to encounter in real production use.

What should be tested?

  • missing information,
  • duplicates and conflicting records,
  • unexpected formats,
  • very short and very long inputs,
  • user input errors,
  • multilingual data,
  • outdated information,
  • rare scenarios and edge cases.

Red flag: the evaluation dataset contains only a handful of examples that were previously used to design the prompt. Such a test may confirm known scenarios but tells the team very little about behaviour on unseen inputs.

If problems already exist at the level of source systems, ownership, freshness or pipelines, first assess whether your data is ready for AI.

2. How do you test RAG and retrieval?

In a RAG architecture, answer quality depends on more than the capabilities of the LLM. The system first needs to retrieve the right knowledge. If retrieval returns irrelevant or incorrect documents, the model may generate a highly convincing answer based on the wrong context.

Question → retrieval → context → LLM → answer

Evaluation should therefore be separated into at least two levels:

Retrieval quality

Does the system retrieve the documents and passages that are actually required to answer the question?

Answer quality

Does the model use the retrieved context correctly without introducing unsupported information?

RAG testing should verify, among other things:

  • whether the correct document appears among the retrieved results,
  • whether retrieval returns too much irrelevant context,
  • how the system behaves when the answer does not exist in the knowledge base,
  • whether updated information becomes available after a source document changes,
  • whether users receive answers based only on information they are authorised to access,
  • whether chunking and indexing cause important context to be lost.

Important: switching to a stronger model will not solve the problem if the correct information never reaches the context window. Retrieval testing should therefore be a separate part of the QA strategy for RAG systems.

Expert source: Microsoft Foundry separates RAG evaluation into answer-quality evaluation and retrieval-process evaluation, including dimensions such as groundedness, relevance and document retrieval. See Microsoft Foundry RAG Evaluators.

3. How do you evaluate LLM outputs?

Generative AI often does not have a single perfect answer that can be stored as a traditional expected result. Teams therefore need explicitly defined evaluation criteria.

CriterionEvaluation question
CorrectnessIs the answer factually correct?
GroundednessIs the answer supported by the provided context without introducing unsupported claims?
CompletenessDoes it contain the information required by the user in the target process?
RelevanceDoes it answer the actual question rather than generate unrelated content?
Instruction followingDoes the system follow the rules and output format defined for the use case?
Uncertainty / abstentionCan the system refrain from answering when reliable information is insufficient?

Build a representative evaluation dataset

A useful evaluation baseline is a stable set of representative scenarios containing user inputs, required context, acceptance criteria and cases where the system should refuse to answer or request additional information.

Such a dataset makes it possible to compare new prompt versions, model versions, retrieval configurations and other changes against the same quality criteria. This helps determine not only whether a change improves one scenario, but also whether it introduces regressions elsewhere.

Automated evaluation does not have to mean fully automated decision-making. Some criteria can be measured automatically, while others may require domain expertise. For higher-impact use cases, combining automated evaluation with human review is often more useful than relying on a single evaluator.

4. AI security testing: what happens when the user or input data does not follow the intended scenario?

AI systems should not be tested only against valid user requests. A user may attempt to bypass restrictions, access sensitive information or alter the intended behaviour of the system. Threats may also originate from external content processed by the AI system.

Scenarios worth including:

  • direct prompt injection – malicious instructions provided directly by the user,
  • indirect prompt injection – malicious instructions embedded in documents, websites, messages or other content processed by the AI system,
  • attempts to expose system instructions,
  • attempts to access another user’s data,
  • manipulated input formats or structures,
  • RAG poisoning – introducing content into the knowledge base with the intention of influencing model behaviour,
  • attempts to force the system to operate outside its defined role,
  • manipulation of agent tools or tool-call parameters.

Particularly important for RAG and AI agents: the AI layer should not allow users to retrieve information or perform operations they are not authorised to access in the underlying systems.

Expert source: OWASP describes both direct and remote/indirect prompt injection, as well as risks such as RAG poisoning and attack scenarios relevant to agentic systems. See the OWASP LLM Prompt Injection Prevention Cheat Sheet.

5. How do you test AI agents and the actions they perform?

A wrong answer from a chatbot may primarily create an information problem. An error in an agentic system can have a broader impact because the AI may modify a record, send a message, create a ticket, call an API or trigger another business process.

Testing AI agents should therefore cover not only the quality of the final outcome, but also the observable execution path and boundaries of autonomy: which tools the agent selects, which parameters it passes, in what order it performs actions and when it should stop and request human approval.

AreaTest question
Task completionDid the agent actually complete the intended task?
Tool selectionDoes the agent select the correct and necessary tool?
Tool inputDoes it send the correct parameters and values to the API?
PermissionsCan it perform only the operations available to the relevant user or role?
SequenceAre actions performed in the correct order without unnecessary steps?
Human approvalDoes an action requiring approval stop before execution?
Failure handlingWhat happens when an API call fails or part of the workflow cannot be completed?

The most important test is not only: “Can the agent complete the task?”
It should also answer: “Can the agent stop when it lacks sufficient information, permissions or required approval?”

Expert source: Microsoft Foundry distinguishes between evaluating the overall result of an agent workflow and evaluating the individual steps in the process. Process-level evaluation can include tool selection, tool input accuracy, tool output utilisation and tool-call success. See Microsoft Foundry Agent Evaluators.

6. Latency, availability and cost: AI also requires non-functional testing

An AI system can produce excellent answers and still be unsuitable for production. Response time, API limitations, scalability or the cost of each interaction may become the real blocker.

Before production, test:

  • response time for different request types,
  • behaviour under concurrent user load,
  • timeouts and retry mechanisms,
  • behaviour when the model provider or another external API is unavailable,
  • provider limits and rate limits,
  • fallback mechanisms,
  • average cost per interaction or business process,
  • the impact of context length on latency and cost,
  • behaviour with very large inputs.

A Proof of Concept can show that AI works. Pre-production testing needs to answer a different question: will the solution remain fast, stable and economically viable under real-world usage?

This is often where problems hidden during demonstrations become visible. We discuss these challenges in more detail in our guide to why AI projects stall between PoC and production.

7. AI QA does not end at deployment: regression testing and production monitoring

In traditional software, a new code release is an obvious trigger for regression testing. AI systems have more potential sources of behavioural change.

Regression testing should be considered after changes to:

  • the model or model version,
  • the model provider,
  • the system prompt,
  • prompt templates,
  • generation parameters,
  • the embedding model,
  • chunking or retrieval logic,
  • data sources,
  • tools available to an agent,
  • permissions or integrations.

What should be monitored after deployment?

AreaExample
QualityA decline in answer quality for specific categories of requests.
ErrorsFailures in model APIs, retrieval or connected tools.
LatencyIncreasing response times.
CostIncreasing cost per interaction or business process.
UsageChanges in how users interact with the system.
Security eventsUnusual attempts to retrieve information or execute actions.

In AI systems, production becomes part of the QA process. Pre-deployment testing remains essential, but the production environment exposes real combinations of inputs, user behaviour and operating conditions that may be difficult to reproduce fully in advance.

Expert source: NIST highlights the difference between pre-deployment evaluation in controlled environments and post-deployment monitoring in real operating conditions, including the need to identify unexpected outputs and consequences that emerge in use. See NIST AI 800-4 – Challenges to the Monitoring of Deployed AI Systems.

How do you define acceptance criteria for an AI system?

Running tests alone does not tell the team whether the system is ready for production. The project needs acceptance criteria that define what level of quality, risk, performance and cost is acceptable for the specific use case.

There is no universal threshold that works for every AI system. An internal assistant used to search documentation may have different requirements from an agent performing operations in a financial system. Acceptance criteria should reflect the use case, the consequences of potential errors and the organisation’s risk tolerance.

AreaExample criterionGo/no-go question
RetrievalAbility to retrieve the correct sources across defined test scenarios.Does the system consistently provide the model with the context required to answer?
Output qualityEvaluation score based on correctness, groundedness, completeness or another defined rubric.Is answer quality sufficient for the target business process?
AgentTask completion and correctness of tool selection and parameters.Does the agent complete the correct task without performing unwanted actions?
SecurityNo access to data or operations outside the permitted scope.Did negative testing reveal any scenario in which permissions could be bypassed?
PerformanceAcceptable latency under expected load.Does response time support the target business process?
CostMaximum acceptable cost per interaction or completed process.Does the solution remain economically viable at target scale?

Do not start with an arbitrary target such as “95% quality”. First identify which errors are critical, what impact they have on users or business processes, and which scenarios must work reliably. Specific thresholds can then be defined against those requirements.

AI testing checklist: is the system ready for production validation?

Before release, check whether the team can confidently answer “yes” to the following questions.

  1. Do we have a representative set of test scenarios?
  2. Does it include errors, edge cases and negative scenarios?
  3. Do we measure retrieval quality separately from answer quality?
  4. Have we defined acceptance criteria and go/no-go thresholds for critical scenarios?
  5. Do we know how the system should behave when reliable information is unavailable?
  6. Do we test both direct and indirect prompt injection and attempts to bypass safeguards?
  7. Are permissions enforced within RAG and agent workflows?
  8. Is the agent prevented from performing actions outside its permitted scope?
  9. Do higher-impact actions require the appropriate approval mechanism?
  10. Have we tested latency, load, timeouts and provider unavailability?
  11. Do we understand the expected operating cost at target usage?
  12. Do model, prompt, retrieval and data changes trigger regression testing?
  13. Can we reproduce the model, prompt, data and configuration used for a particular output?
  14. Do we monitor system quality and behaviour after production deployment?

Mostly YES

The team can move towards a controlled release and production observation against the defined acceptance criteria.

Many WE DON’T KNOW answers

Quality criteria, observability, acceptance thresholds and reproducibility should be defined before the release decision.

Many NO answers

Releasing the system may transfer unidentified risk directly to users and business processes.

How can Edge One Solutions support AI system testing?

At Edge One Solutions, we look at AI system quality beyond the model itself. A production solution also includes data, applications, integrations, access control, infrastructure and the operating model used after deployment.

Depending on the architecture and use case, we can combine QA, Artificial Intelligence, Data Engineering, development and maintenance capabilities to design testing across the entire system flow.

Testing & Quality Assurance

Test strategy, automation, regression, integrations, system testing and non-functional testing.

Artificial Intelligence

Solution architecture, LLMs, RAG, AI component integration and preparation for production.

Data Engineering

Data quality, source systems, pipelines, integrations and preparation of the data layer supporting AI.

Managed Services

Monitoring, maintenance and operational control after production deployment.

If your project is still at an earlier stage, start by assessing whether your data is ready for AI. If the PoC already works but scaling, integrations and operations remain unresolved, see our guide to moving AI from PoC to production.

For AI solutions affected by regulatory requirements, see our guide to the technical implications of the EU AI Act for businesses.

Building an AI system and need to validate its quality before production?

We can help design a testing approach covering the application, data, model, RAG, integrations and system behaviour in a production environment.

Explore our Testing & Quality Assurance capabilities

See

What can we do for you?

If you would like to learn more about opportunities to work with us, please fill out the form. Let's get to know each other!

Leave a Reply

Your email address will not be published. Required fields are marked *