[Technical Debt] Add integration tests with real LLM calls using VCR.py
Resolved 💬 3 comments Opened Nov 17, 2025 by roblafave Closed Jan 18, 2026
Summary
Current Agent 7 tests mock all LLM responses, which means they test mocking infrastructure rather than actual LLM behavior. Need integration tests with real LLM calls to catch prompt regressions.
Current State
All tests use AsyncMock for LLM responses:
mock_llm.ainvoke = AsyncMock(return_value=expected_plan)
This means:
- Tests pass even if prompts are broken
- Cannot detect structured output validation issues
- Cannot verify that prompts actually work with Claude
Problems
- False confidence: Tests pass but prompts may fail in production
- Prompt regressions undetected: Changes to prompts not validated
- No real-world validation: Cannot verify Claude actually returns expected structure
- Debugging difficulty: Production prompt issues hard to reproduce in tests
Proposed Solution
Use VCR.py (or similar) to record/replay real LLM interactions:
@pytest.mark.vcr() # Records first run, replays after
async def test_planning_with_real_llm():
llm = ChatAnthropic(model="claude-3-5-sonnet-20241022")
plan = await generate_execution_plan(
workflow_type="order_creation",
trigger_data=real_trigger_data,
context=real_context,
available_tools=real_tools,
llm=llm
)
# Verify actual LLM response structure
assert len(plan.tasks) > 0
assert plan.tasks[0].tool_name.count('.') == 2 # Real validation
Benefits:
- First run makes real API call and records response
- Subsequent runs replay recorded response (fast, no API cost)
- Easy to update recordings when prompts change (
--record-mode=all) - Catches real prompt/schema mismatches
Acceptance Criteria
- [ ] VCR.py (or vcrpy) integrated into test suite
- [ ] Integration test for
generate_execution_plan()with real LLM - [ ] Integration test for
infer_modification_intent()with real LLM - [ ] Integration test for
generate_draft_message()with real LLM - [ ] Integration test for
classify_workflow_type()with real LLM - [ ] Documentation on updating VCR cassettes when prompts change
- [ ] CI pipeline runs with recorded cassettes (no API calls in CI)
Test Strategy
tests/
llm/
test_planning.py # Unit tests (mocked)
integration/
cassettes/ # VCR recordings
test_planning_integration.py # Integration tests (VCR)
Priority
Medium - Important for confidence in production behavior
Estimated Effort
4-6 hours (setup VCR, write 4-5 integration tests, document process)
Dependencies
- Install
vcrpyorpytest-vcr - Anthropic API key in test environment (for initial recording only)
Related
- Agent 7 (LLM Modules)
- All
tests/llm/test_*.pyfiles - Prompt engineering quality assurance
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗