Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Jan 15, 2025

Important

Adds a check in on_chain_error() in langchain.py to log a warning if run_id is missing, preventing errors from accessing non-existent runs.

  • Behavior:
    • In on_chain_error() in langchain.py, added check for run_id existence in self.runs before ending run and updating trace.
    • Logs a warning if run_id is not found, instead of raising an exception.

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

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

Improved error handling in the LangchainCallbackHandler to prevent crashes when run_id is missing during chain errors.

  • Added defensive check in langfuse/callback/langchain.py to verify run_id exists before accessing runs dictionary
  • Implemented warning log message when run_id is not found instead of raising KeyError
  • Enhanced error handling robustness for LangChain integration error scenarios

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

@hassiebp hassiebp merged commit 40cb0e1 into main Jan 15, 2025
4 of 9 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-2096-mitigate-on-chain-end-error branch January 15, 2025 13:49
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: Langfuse run not found in on_chain_ned with LangChain AgentExecutor

2 participants