test(langchain): Add text completion test #5740
4 issues
High
Test filters for wrong span operation type 'gen_ai.pipeline' instead of 'gen_ai.generate_text' - `tests/integrations/langchain/test_langchain.py:155-158`
The test filters spans by op == "gen_ai.pipeline" but the LangchainIntegration creates text completion spans with op=OP.GEN_AI_GENERATE_TEXT ("gen_ai.generate_text"). Other similar tests in this file correctly use "gen_ai.generate_text" (lines 1291, 2005). This will cause the test to not find any matching spans and fail at assert len(llm_spans) > 0.
Test filters for wrong span operation type, will never match LLM spans - `tests/integrations/langchain/test_langchain.py:156`
The test filters for spans with op == "gen_ai.pipeline", but the langchain integration's on_llm_start method creates spans with op = OP.GEN_AI_GENERATE_TEXT which equals "gen_ai.generate_text". This causes the filter to find zero spans, and the assertion assert len(llm_spans) > 0 will fail, making the test ineffective.
Test expects incorrect span description "Langchain LLM call" instead of "generate_text gpt-3.5-turbo" - `tests/integrations/langchain/test_langchain.py:161`
The test asserts that llm_span["description"] == "Langchain LLM call", but the langchain integration's on_llm_start method sets the span name (which becomes the description) to f"generate_text {model}".strip(). For the model "gpt-3.5-turbo", this would be "generate_text gpt-3.5-turbo".
Medium
Loss of test coverage for langchain-core-only installation scenario - `tests/integrations/langchain/test_langchain.py:1093-1098`
The deleted test_langchain_integration_with_langchain_core_only test uniquely verified that the integration works when AgentExecutor is None (i.e., when only langchain-core is installed, but not the full langchain package). The replacement test_langchain_text_completion test uses the actual langchain library and does not cover this edge case. This reduces coverage for users who only have langchain-core installed.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| code-review | 2 | 3m 25s | $1.31 |
| find-bugs | 2 | 2m 40s | $1.56 |
| skill-scanner | 0 | 1m 12s | $0.44 |
| security-review | 0 | 1m 6s | $0.65 |
Duration: 8m 24s · Tokens: 2.3M in / 18.0k out · Cost: $3.99 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.01, +dedup: $0.01, +consolidate: $0.00)