Features/langfuse tests#7
Merged
Merged
Conversation
Observability: - Added current_span ContextVar to track active LangGraph node span. - Wrapped all agent nodes (base, core, loop) with manual Langfuse spans; LLM callbacks are now scoped to the node span via CallbackHandler(stateful_client=span). - Updated RedisAdapter and ChromaAdapter to nest their spans under current_span instead of attaching directly to the root trace. - Removed global CallbackHandler from /chat router to avoid duplicate spans. Tests: - Added tests/service/api/v1/test_router.py covering /test_invoke (success & 424) and /chat (success & rate-limit). - Added tests/agents/profkom_consultant/nodes/test_base.py for update_user_history_context (append, trim, 1:1 sync). Fixes: - Fixed history trim bug: model_answers now uses [-HISTORY_LIMIT:] instead of [-trim_count:], keeping Q&A lists synchronized. Deps: - Added pytest, pytest-asyncio, httpx to dev dependencies.
- Added pytest-cov to dev dependencies. - Generated coverage.xml from current test suite (7 tests, all passing).
Added pytest suites covering: - redis_ext: RedisAdapter (save/get/spans/health) + UserRateLimiter (incr/remain/reset/ttl/health) - chroma_ext: ChromaAdapter (init/query/filter/rerank/RAG), MyEmbeddingFunction (retry/batch/call), BM25Reranker (fit/rerank), data_reader (chunk/signature/topic), db_writer (sync/orphan cleanup) - postgres_ext: PostgresClient (pool lifecycle, conn loop, checkpointer, stats, close, health) - langfuse_ext: LangfuseClient (init, client/handler creation, health_check, on_startup) Fixes: - Fixed f-string bug in PostgresClient.get_pool_stats that raised ValueError at runtime. Coverage: - Regenerated coverage.xml from full suite (102 tests passing).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Добавлено полное unit-test покрытие для всех интеграций в
src/modules/, исправлен production-баг и обновлён README с бейджами.Changes
tests/modules/):redis_ext—RedisAdapter(span wrapping, save/get) +UserRateLimiter(INCR/EXPIRE pipeline) — 24 тестаchroma_ext—ChromaAdapter(query/RAG, filtering, reranking) +MyEmbeddingFunction(retry/backoff) +BM25Reranker+data_reader/db_writer— 52 тестаpostgres_ext—PostgresClient(pool lifecycle, double-checked locking, health) — 12 тестовlangfuse_ext—LangfuseClient(init, auth check, startup) — 7 тестовPostgresClient.get_pool_stats, который падал сValueErrorпри вызовеcoverage.xmlперегенерирован по всем 102 тестам