Skip to content

[Agent] Mop-up: harden LangChain runtime imports + pipeline test compatibility#310

Merged
stranske merged 3 commits intomainfrom
codex/mopup-langchain-runtime-fix
Mar 1, 2026
Merged

[Agent] Mop-up: harden LangChain runtime imports + pipeline test compatibility#310
stranske merged 3 commits intomainfrom
codex/mopup-langchain-runtime-fix

Conversation

@stranske
Copy link
Copy Markdown
Owner

@stranske stranske commented Mar 1, 2026

Summary

  • move chat-provider LangChain runtime helpers into src so packaged/src-only execution no longer depends on importing repository-root tools.*
  • update counter_risk.chat.providers.base to use the new runtime-safe module
  • clean up mypy handling for parquet context imports and add explicit module override for counter_risk.chat.context
  • fix tests/pipeline/test_run_pipeline.py monkeypatch signatures for _update_historical_outputs(..., formatting_profile=...) so full suite remains green after formatting-profile integration

Why

A follow-up audit found one real readiness risk: importing counter_risk.chat.session could fail with ModuleNotFoundError: tools in 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.toml
  • black --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
  • mypy src
  • pytest -q tests/chat/test_top_exposures.py tests/test_chat_provider_clients.py tests/test_chat_session.py
  • pytest -q tests/pipeline/test_run_pipeline.py
  • pytest -q (full suite) -> 1091 passed, 2 skipped

Copilot AI review requested due to automatic review settings March 1, 2026 03:03
@agents-workflows-bot
Copy link
Copy Markdown
Contributor

⚠️ Action Required: Unable to determine source issue for PR #310. The PR title, branch name, or body must contain the issue number (e.g. #123, branch: issue-123, or the hidden marker ).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to provide runtime-safe LangChain client construction and metadata helpers (no dependency on repo-root tools.*).
  • Updated counter_risk.chat.providers.base to 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.

@stranske-keepalive
Copy link
Copy Markdown
Contributor

stranske-keepalive bot commented Mar 1, 2026

🤖 Keepalive Loop Status

PR #310 | Agent: Codex | Iteration 0/5

Current State

Metric Value
Iteration progress [----------] 0/5
Action wait (missing-agent-label)
Disposition skipped (transient)
Gate success
Tasks 0/10 complete
Timeout 45 min (default)
Timeout usage 5m elapsed (12%, 40m remaining)
Keepalive ❌ disabled
Autofix ❌ disabled

🔍 Failure Classification

| Error type | infrastructure |
| Error category | resource |
| Suggested recovery | Confirm the referenced resource exists (repo, PR, branch, workflow, or file). |

@stranske-keepalive
Copy link
Copy Markdown
Contributor

stranske-keepalive bot commented Mar 1, 2026

Keepalive Work Log (click to expand)
# Time (UTC) Agent Action Result Files Tasks Progress Commit Gate
0 2026-03-01 03:08:59 Codex wait (missing-agent-label-transient) skipped 0 0/10 success
0 2026-03-01 03:33:49 Codex wait (missing-agent-label-transient) skipped 0 0/10 success
0 2026-03-01 03:40:24 Codex wait (missing-agent-label-transient) skipped 0 0/10 success

@stranske
Copy link
Copy Markdown
Owner Author

stranske commented Mar 1, 2026

Applied the inline feedback in commit 1763c3b:

  • _resolve_provider() now treats env provider as explicit only when it normalizes to a known provider (invalid env values no longer disable slot fallback).
  • _load_slot_config() now guards against non-object JSON payloads and falls back to defaults.
  • build_langsmith_metadata() now restores LangSmith tracing env setup when LANGSMITH_API_KEY is present (LANGCHAIN_TRACING_V2, LANGCHAIN_API_KEY, default project).
  • Added focused regression tests in tests/test_langchain_runtime.py for all three behaviors.

@stranske
Copy link
Copy Markdown
Owner Author

stranske commented Mar 1, 2026

Expanded this PR to cover the remaining formatting-scope gap identified during the PR #308 acceptance review:

  • added formatting_profile support to CPRS table PNG renderers (render_cprs_ch_png / render_cprs_fcm_png),
  • implemented profile-aware numeric text formatting for default/plain/currency/accounting,
  • added renderer tests for currency symbol + accounting-negative parentheses,
  • updated docs to reflect current formatting-profile application scope.

Validation run locally:

  • ruff check src/counter_risk/renderers/table_png.py tests/test_table_png.py tests/renderers/test_table_png.py
  • black --check src/counter_risk/renderers/table_png.py tests/test_table_png.py tests/renderers/test_table_png.py
  • pytest -q tests/test_table_png.py tests/renderers/test_table_png.py
  • mypy src

@stranske stranske merged commit dd6fae2 into main Mar 1, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants