Skip to content

Conversation

@yaricom
Copy link
Contributor

@yaricom yaricom commented Nov 7, 2025

Details

Allows to skip specific errors with LangChain/LangGraph integration

  • Introduced skip_error_callback to allow selective skipping of error outputs during trace handling.
  • Updated OpikTracer to incorporate conditional error handling based on the callback's result.
  • Enhanced error processing logic to handle skipped errors with placeholder outputs.
  • Added integration test test_langchain_callback__skip_error_callback__error_output_skipped.

Example of usage

from opik.integrations.langchain.opik_tracer import OpikTracer

def _should_skip_error(error: str) -> bool:
    if error is not None and error.startswith("FakeListLLMError"):
        # skip processing - we are sure that this is OK
        return True
    else:
        return False

callback = OpikTracer(
    skip_error_callback=_should_skip_error,
)

Result in UI

Screenshot 2025-11-07 at 17 46 52

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-2787

Testing

Implemented related integration test.

Documentation

Nothing added

…er for LangChain integration

- Introduced `skip_error_callback` to allow selective skipping of error outputs during trace handling.
- Updated `OpikTracer` to incorporate conditional error handling based on the callback's result.
- Enhanced error processing logic to handle skipped errors with placeholder outputs.
- Added integration test `test_langchain_callback__skip_error_callback__error_output_skipped`.
@yaricom yaricom requested a review from a team as a code owner November 7, 2025 16:30
Copilot AI review requested due to automatic review settings November 7, 2025 16:30
Copy link
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 introduces selective error skipping functionality for the LangChain/LangGraph integration to prevent GeneratorExit errors from being logged as failures. A new skip_error_callback parameter allows users to define custom logic for determining which errors should be skipped during trace handling, with skipped errors resulting in a placeholder output instead of error information.

Key Changes:

  • Added skip_error_callback parameter to OpikTracer for conditional error handling
  • Implemented _should_skip_error method to evaluate error skipping logic
  • Introduced ERROR_SKIPPED_OUTPUTS constant as placeholder for skipped errors
  • Updated error processing in _persist_run and _process_end_span_with_error methods

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
sdks/python/src/opik/integrations/langchain/opik_tracer.py Added skip_error_callback parameter, implemented error skipping logic in error handling methods
sdks/python/tests/library_integration/langchain/test_langchain.py Added integration test verifying error skipping functionality with FakeStreamingListLLM

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

SDK E2E Tests Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit ba0ce46. ± Comparison against base commit f303a9b.

♻️ This comment has been updated with latest results.

…utput handling

- Updated `OpikTracer` to improve error processing flow and conditional skipping logic using `skip_error_callback`.
- Introduced explicit handling for placeholder outputs when errors are skipped.
- Corrected typo in test prompt template for clarity.
…zation parameters

- Revised and expanded `OpikTracer` constructor docstring to provide clearer descriptions for initialization parameters.
- Removed duplicated docstring content for improved clarity and reduced redundancy.
@yaricom yaricom merged commit 34ec40b into main Nov 10, 2025
99 checks passed
@yaricom yaricom deleted the OPIK-2787-generatorexit-langgraph branch November 10, 2025 12:55
awkoy pushed a commit that referenced this pull request Nov 12, 2025
…3986)

* [OPIK-2787] [P SDK] Add skip error callback functionality in OpikTracer for LangChain integration

- Introduced `skip_error_callback` to allow selective skipping of error outputs during trace handling.
- Updated `OpikTracer` to incorporate conditional error handling based on the callback's result.
- Enhanced error processing logic to handle skipped errors with placeholder outputs.
- Added integration test `test_langchain_callback__skip_error_callback__error_output_skipped`.

* [OPIK-2787] [P SDK] Refine skip error logic and enhance placeholder output handling

- Updated `OpikTracer` to improve error processing flow and conditional skipping logic using `skip_error_callback`.
- Introduced explicit handling for placeholder outputs when errors are skipped.
- Corrected typo in test prompt template for clarity.

* [OPIK-2787] [P SDK] Update `OpikTracer` docstring format for initialization parameters

- Revised and expanded `OpikTracer` constructor docstring to provide clearer descriptions for initialization parameters.
- Removed duplicated docstring content for improved clarity and reduced redundancy.
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.

3 participants