Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Jun 27, 2025

Important

Add last_trace_id property to LangchainCallbackHandler to track the last run's trace ID in CallbackHandler.py.

  • Feature:
    • Add last_trace_id property to LangchainCallbackHandler in CallbackHandler.py.
    • Update last_trace_id in on_chain_start() and __on_llm_action() to store the trace ID of the last run.

This description was created by Ellipsis for 43cc5ff. You can customize this summary. It will automatically update as commits are pushed.

Greptile Summary

Disclaimer: Experimental PR review

Added last_trace_id property to langchain CallbackHandler for easier access to the most recent trace identifier without parsing the runs dictionary.

  • Added new property last_trace_id in langfuse/langchain/CallbackHandler.py that tracks the most recently used trace ID
  • Updated property during chain start, LLM generation start, and LLM action events
  • Implementation maintains existing error handling patterns and integrates with current tracing functionality
  • Feature supports better tracing/debugging in LangChain integration as shown in test cases

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.

LGTM

1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile

@hassiebp hassiebp merged commit 057ad66 into main Jun 27, 2025
8 of 10 checks passed
@hassiebp hassiebp deleted the add-last-trace-id-callbackhandler branch June 27, 2025 14:19
@chai3
Copy link

chai3 commented Jun 29, 2025

very nice for me

I was in trouble because CallbackHandler.get_trace_url() was removed in v3.
I think that client.get_trace_url(callback_handler.last_trace_id) will be available.

@hassiebp
Copy link
Contributor Author

very nice for me

I was in trouble because CallbackHandler.get_trace_url() was removed in v3.

I think that client.get_trace_url(callback_handler.last_trace_id) will be available.

thanks for your feedback @chai3 !

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