[Agent] Mop-up: harden LangChain runtime imports + pipeline test compatibility#310
[Agent] Mop-up: harden LangChain runtime imports + pipeline test compatibility#310
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens chat-provider LangChain integration for packaged/src-only execution by moving runtime helpers into the src/ tree, updating imports accordingly, and keeping the pipeline test suite compatible with the new formatting-profile plumbing.
Changes:
- Added
src/counter_risk/chat/providers/langchain_runtime.pyto provide runtime-safe LangChain client construction and metadata helpers (no dependency on repo-roottools.*). - Updated
counter_risk.chat.providers.baseto import LangChain helpers from the new runtime module. - Adjusted mypy configuration and pipeline tests to remain compatible with optional parquet deps and the new
_update_historical_outputs(..., formatting_profile=...)signature.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/pipeline/test_run_pipeline.py | Updates monkeypatch stubs to accept formatting_profile kwarg for historical output updates. |
| src/counter_risk/chat/providers/langchain_runtime.py | New runtime-safe LangChain helper module under src/ for packaged execution. |
| src/counter_risk/chat/providers/base.py | Switches imports from tools.* to the new langchain_runtime module. |
| src/counter_risk/chat/context.py | Removes inline mypy import ignores for pyarrow/pandas optional imports (now handled via mypy overrides). |
| pyproject.toml | Adds a mypy override for counter_risk.chat.context to disable import-untyped/import-not-found. |
🤖 Keepalive Loop StatusPR #310 | Agent: Codex | Iteration 0/5 Current State
🔍 Failure Classification| Error type | infrastructure | |
Keepalive Work Log (click to expand)
|
|
Applied the inline feedback in commit
|
|
Expanded this PR to cover the remaining formatting-scope gap identified during the PR #308 acceptance review:
Validation run locally:
|
Summary
srcso packaged/src-only execution no longer depends on importing repository-roottools.*counter_risk.chat.providers.baseto use the new runtime-safe modulecounter_risk.chat.contexttests/pipeline/test_run_pipeline.pymonkeypatch signatures for_update_historical_outputs(..., formatting_profile=...)so full suite remains green after formatting-profile integrationWhy
A follow-up audit found one real readiness risk: importing
counter_risk.chat.sessioncould fail withModuleNotFoundError: toolsin src-only/package-style execution. This PR removes that dependency path and closes the remaining test compatibility gaps.Validation
ruff check src/counter_risk/chat/providers/langchain_runtime.py src/counter_risk/chat/providers/base.py src/counter_risk/chat/context.py tests/pipeline/test_run_pipeline.py pyproject.tomlblack --check src/counter_risk/chat/providers/langchain_runtime.py src/counter_risk/chat/providers/base.py src/counter_risk/chat/context.py tests/pipeline/test_run_pipeline.pymypy srcpytest -q tests/chat/test_top_exposures.py tests/test_chat_provider_clients.py tests/test_chat_session.pypytest -q tests/pipeline/test_run_pipeline.pypytest -q(full suite) ->1091 passed, 2 skipped