
When AI Works in Testing but Fails in Production: The Hidden Challenge of AI Observability
Exploring why AI applications behave differently in production and how monitoring, evaluation, and AWS observability tools can help.
Introduction: The Demo Worked Perfectly. What Went Wrong?
Imagine spending weeks building an AI-powered assistant.
It answers questions correctly, retrieves relevant documents, and completes tasks during testing. Everything looks promising.
You deploy it.
Then something unexpected happens.
A user asks a slightly different question, and the assistant produces an incorrect answer. Another request takes unusually long. A third triggers repeated tool calls, increasing operational costs.
Interestingly, the application itself hasn't crashed.
From a traditional monitoring perspective, everything might appear healthy.
This raises an important question:
If an AI application is technically running, does that necessarily mean it is working correctly?
Not always.
In my previous articles, I explored how Retrieval-Augmented Generation (RAG) connects AI with external knowledge and how agentic AI extends language models with tools and workflows.
But there is another important part of this journey that deserves attention: what happens after these systems are deployed?
This brings us to AI observability.
Why Traditional Monitoring Is Not Enough
Traditional software applications are generally built around defined instructions and predictable execution paths.
When something goes wrong, developers can investigate exceptions, failed API requests, resource consumption, and system logs.
Generative AI applications introduce a different kind of complexity.
A language model can return a technically successful response that is factually incorrect.
An AI agent can execute an authorized tool but select the wrong one.
A RAG application can retrieve documents successfully while missing the information needed to answer the user's question.
None of these situations necessarily produces a conventional software error.
Consider a document assistant that receives the question:
"What is the latest reimbursement policy?"
The application responds with a well-written explanation, and the API returns HTTP 200.
Technically, the request succeeded.
But what if the answer came from an outdated policy document?
The infrastructure is healthy, but the information is unreliable.
This is why monitoring AI systems requires more than checking whether servers and APIs are available.
What Exactly Is AI Observability?
AI observability is the ability to understand how an AI application behaves by collecting and analyzing relevant operational and application-level signals.
It helps developers investigate questions such as:
- How long does the model take to respond?
- How many tokens are consumed?
- Which documents were retrieved?
- Did the agent select the correct tool?
- Is the response supported by relevant evidence?
- Are errors or unexpected costs increasing?
- Has application quality changed since deployment?
Observability does not automatically solve these problems.
Instead, it provides the visibility needed to identify, investigate, and address them.
For generative AI applications, I find it useful to think about observability across three dimensions.
Performance: Is the application responding efficiently?
Reliability: Is it completing tasks consistently?
Quality: Are the generated responses useful, accurate, and supported by evidence?
A mature monitoring strategy needs to consider all three.
The Hidden Problem: Successful Requests Can Still Be Failures
One of the most interesting differences between conventional applications and generative AI systems is how we define success.
In traditional software, a successful API response often indicates that an operation completed as expected.
With generative AI, that conclusion can be misleading.
Imagine an AI assistant that processes 1,000 questions.
All 1,000 requests return successfully.
The infrastructure dashboard reports a 100% successful response rate.
However, after evaluating the responses, developers discover that a portion contains unsupported claims or incomplete information.
The system has achieved operational success without necessarily achieving answer quality.
This creates two separate questions:
Did the system execute successfully?
And:
Did the system produce the correct result?
Both matter, but they require different measurements.
Five Signals Worth Monitoring in AI Applications
1. Response Latency
Latency measures how long an application takes to respond.
A chatbot that takes several seconds to answer a simple question may frustrate users.
For AI agents, delays can become more complicated because a single request may involve multiple model invocations, database searches, and external tools.
Monitoring average latency is useful, but examining percentile measurements such as P95 and P99 can reveal slower requests that averages might hide.
2. Token Consumption and Cost
Language model usage often depends on the number of input and output tokens processed.
A poorly designed workflow might repeatedly send unnecessary context or invoke models more frequently than required.
Monitoring token consumption helps identify inefficiencies.
For example, if a RAG application retrieves excessively large document chunks, it may increase token usage without improving response quality.
Tracking usage alongside task outcomes can help developers make better architectural decisions.
3. Retrieval Quality
For RAG applications, the quality of retrieved information strongly influences the generated response.
Useful evaluation questions include:
- Were relevant documents retrieved?
- Did the system retrieve outdated information?
- Was important context missing?
- Did the answer accurately reflect the retrieved sources?
These measurements generally require application-level instrumentation and evaluation rather than relying solely on infrastructure metrics.
4. Agent Tool Execution
AI agents introduce additional complexity because they can interact with external tools.
Monitoring should help developers understand which tools were selected, whether their arguments were valid, how long execution took, and whether the results were used correctly.
For example, an agent might repeatedly call a search tool without making progress.
The individual calls may succeed, but the overall workflow may still fail.
Tracing the execution sequence can help reveal this behavior.
5. Response Quality and Safety
Not every AI failure can be detected through automated infrastructure monitoring.
Developers may need evaluation datasets, automated quality checks, user feedback, and human review.
Important dimensions include factual correctness, faithfulness to retrieved evidence, task completion, and compliance with application-specific safety requirements.
The exact measurements depend on the use case.
A customer support assistant, research assistant, and financial analysis system should not necessarily use identical quality thresholds.
Exploring AI Observability with AWS
AWS provides several capabilities that can support monitoring and troubleshooting generative AI applications.
Amazon CloudWatch provides metrics, logs, dashboards, and alarms for monitoring applications and AWS resources.
For Amazon Bedrock model invocations, CloudWatch can help track operational signals such as invocation counts, latency, token consumption, and errors.
Amazon Bedrock also supports model invocation logging for supported runtime operations. When explicitly enabled, this can capture request and response information in configured destinations such as CloudWatch Logs or Amazon S3.
For agent-based applications, Amazon Bedrock AgentCore Observability can provide deeper visibility into agent execution through telemetry such as traces, metrics, and structured logs.
This is particularly valuable when investigating complex workflows involving multiple tool calls.
However, operational telemetry alone cannot establish whether an AI-generated answer is factually correct.
That still requires appropriate evaluation mechanisms.
A Practical Example: Monitoring a RAG-Based Assistant
Consider a hypothetical AI assistant built to answer questions from organizational documents.
The application uses Amazon Bedrock for model inference and a knowledge base for document retrieval.
A user asks:
"What is the current approval process for travel expenses?"
The system retrieves relevant documents and generates a response.
Now imagine the answer is incorrect.
With suitable instrumentation, developers could investigate the problem in stages.
Stage 1: Check the model invocation
Was the request completed successfully? Were there unusual delays or errors?
Stage 2: Inspect the retrieval process
Which documents were retrieved? Were they relevant and current?
Stage 3: Evaluate the generated answer
Did the response accurately reflect the retrieved information?
Stage 4: Identify the root cause
Was the issue caused by outdated documents, poor retrieval, insufficient context, or unsupported generation?
Stage 5: Implement improvements
Possible improvements include updating the knowledge base, adjusting retrieval settings, revising prompts, or adding validation.
This is a conceptual investigation workflow rather than a description of an implemented project.
The important idea is that observability should help explain why a failure occurred, not simply indicate that something went wrong.
The Privacy Challenge Nobody Should Ignore
There is another important consideration.
Monitoring AI applications may involve collecting prompts, retrieved documents, generated responses, and tool execution details.
These records can contain sensitive information.
For example, a document assistant may process internal business information or personal data.
Capturing complete inputs and outputs without proper controls could introduce privacy and security risks.
Amazon Bedrock model invocation logging is disabled by default and must be configured explicitly.
Before enabling detailed logging, developers should consider data classification, least-privilege access, encryption, retention policies, and whether sensitive content needs to be excluded or masked.
The objective should be to collect enough information to troubleshoot the application without unnecessarily exposing user data.
Observability should improve trust, not create new privacy risks.
Can We Detect AI Failures Before Users Notice Them?
This is where monitoring becomes particularly interesting.
Imagine tracking an AI application's response quality over time.
Initially, the system performs well against a defined evaluation dataset.
After a knowledge base update, retrieval relevance begins to decline.
If the application has appropriate evaluation pipelines and alert thresholds, developers may detect this deterioration before it affects a larger number of users.
Similarly, increasing latency, error rates, or token consumption could indicate emerging operational problems.
However, predicting every AI failure is unrealistic.
Some failures occur only under unusual inputs, while others require domain expertise to recognize.
The practical objective is to detect meaningful changes early and reduce their impact.
Best Practices for Building Observable AI Systems
A few engineering practices can make a substantial difference.
Define success before deployment. Establish measurable targets for task completion, response quality, latency, and cost.
Create representative evaluation datasets. Include normal questions, ambiguous inputs, edge cases, and known failure scenarios.
Trace important workflows. Capture enough information to investigate retrieval operations, model invocations, and agent tool usage.
Monitor cost alongside quality. A faster or cheaper response is not necessarily better if accuracy deteriorates.
Protect sensitive data. Avoid indiscriminate logging and enforce appropriate access and retention controls.
Keep humans involved. Use human review for high-impact decisions and cases where automated evaluation is insufficient.
Perhaps most importantly, monitoring should be treated as an ongoing engineering responsibility rather than a final deployment step.
Final Thoughts: AI Reliability Doesn't End at Deployment
When learning to build AI applications, it is easy to focus on whether a prototype works.
Can the model answer questions?
Can the RAG system retrieve documents?
Can the agent execute tools?
These are important milestones.
But real-world reliability requires asking a different set of questions.
How does the system behave when inputs change?
What happens when a knowledge source becomes outdated?
Can we identify why an agent selected the wrong tool?
Will we notice if response quality gradually declines?
AI observability helps us investigate these questions.
As I continue exploring generative AI and AWS, I am increasingly interested in the engineering practices that make intelligent applications dependable beyond controlled demonstrations.
Because creating an AI application that works once is an achievement.
Creating one that remains reliable, measurable, and trustworthy as it evolves is the bigger challenge.
And that is where the next stage of AI engineering becomes interesting.
References and Further Reading
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article