Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Jan 27, 2025

Important

Add run_id existence check in on_llm_error and adjust sleep timing in tests for async operations.

  • Behavior:
    • Add run_id existence check in on_llm_error in langchain.py to prevent errors when run_id is not found.
  • Tests:
    • Add sleep(0.1) in test_core_sdk.py and sleep(1) in test_datasets.py to ensure proper timing for asynchronous operations.

This description was created by Ellipsis for f05dcec. It will automatically update as commits are pushed.

@hassiebp hassiebp linked an issue Jan 27, 2025 that may be closed by this pull request
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

Enhanced error handling in the Langchain callback handler by adding a safety check for run_id existence before processing LLM errors.

  • Added defensive check if run_id in self.runs in on_llm_error method within langfuse/callback/langchain.py to prevent KeyErrors
  • Aligns error handling with existing patterns in on_chain_error and on_tool_error methods

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

(updates since last review)

This PR adds timing-related fixes to improve test stability in the test suite.

  • Added time.sleep(1) in tests/test_datasets.py before trace retrieval to ensure data availability
  • Added time.sleep(0.1) in tests/test_core_sdk.py between trace creation and update to prevent race conditions
  • Both changes address potential flakiness in tests by adding small delays at critical points

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@hassiebp hassiebp merged commit 94b42d3 into main Jan 27, 2025
6 of 10 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-3706-lc-on-llm-error branch January 27, 2025 15:51
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.

bug: KeyError in langchain callback in on_llm_error

2 participants