text
stringlengths
0
59.1k
### State and memory implications
LLM agents have retained knowledge between conversations. What the agent responds with is dependent on more than what your immediate question is:
- What happened in prior conversations
- Things in memory
- User state now
- Environment choices
This means tests can affect other tests, and debugging will have to take the whole system state into consideration.
### Use of tools and impact on the external world
Modern AI agents not only generate text - they actually do something in the external world:
- Send emails and notifications
- Book meetings and appointments
- Query databases and APIs
- Process payments and transactions
While evaluating these agents, you need to take into account:
- How to mock external service calls
- How to verify if the right tools were invoked with correct data
- How to verify when the external services are unavailable
- How to verify tools are invoked in the proper order
### Why conventional testing methods fail
Conventional testing systems struggle with:
1. **Random output** - Standard assertions break
2. **Deep interactions** - Agents make many tool calls and thinking steps
3. **State management** - Memory and context control everything
4. **Async behavior** - Agent output contains multiple async operations
5. **Error chains** - Failures can propagate through tool chains and subagents
<ZoomableMermaid chart={`
%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#ecfdf5', 'primaryTextColor':'#064e3b', 'lineColor':'#10b981', 'fontSize':'12px'}}}%%
graph TD
A[User Query] --> B[Agent Processes Input]
B --> C{Agent Reasoning}
C --> D[Choose Tool A]
C --> E[Choose Tool B]
C --> F[Generate Response Only]
D --> G[External API Call]
G --> H[API Response]
H --> I{Continue or Finish?}
E --> J[Database Query]
J --> K[Query Result]
K --> I
F --> L[Generate Final Response]
I --> L
L --> M[Response to User]
classDef agent fill:#10b981,color:#ffffff,font-size:11px
classDef tool fill:#059669,color:#ffffff,font-size:11px
classDef decision fill:#34d399,color:#064e3b,font-size:11px
classDef user fill:#d1fae5,color:#064e3b,font-size:11px
class B,C,I,L agent
class D,E,G,J tool
class A,M user
class F decision
`} />
This is where specialized observability and testing approaches become crucial.
## How Observability Changes LLM Testing
Traditional testing relies on predictable inputs and outputs. LLM testing requires understanding the entire execution flow and decision-making process.
### Understanding execution patterns
Instead of testing specific outputs, we need to understand:
- What decisions the AI made and why
- Which tools were called and in what order
- How memory and context influenced responses
- Where bottlenecks and failures occurred
### Pattern-based testing approaches
Rather than exact output matching, effective LLM testing focuses on:
- **Behavioral patterns** - Does the agent follow expected workflows?
- **Tool usage patterns** - Are the right tools called for specific scenarios?
- **Error handling patterns** - How does the system respond to failures?
- **Performance patterns** - Are response times consistent?
### Testing through observation
The key insight is that LLM testing is more like behavioral analysis than unit testing. You need to:
1. **Observe** how the system behaves under different conditions
2. **Analyze** patterns in the execution traces