Skip to content

Fix improper span closures on errors and LangchainCallbackHandler memory leaks#839

Closed
mpenn wants to merge 4 commits intoNVIDIA:developfrom
mpenn:mpenn_fix-tool-failure-closures
Closed

Fix improper span closures on errors and LangchainCallbackHandler memory leaks#839
mpenn wants to merge 4 commits intoNVIDIA:developfrom
mpenn:mpenn_fix-tool-failure-closures

Conversation

@mpenn
Copy link
Copy Markdown
Contributor

@mpenn mpenn commented Sep 23, 2025

Description

Closes

This PR improves error handling during function invocation and llm/tool call failures in LangchainCallbackHandler to ensure proper closures of spans during export. This ensures proper nesting of traces. This includes an the following updates to the IntermediateStep:

  • addition of IntermediateStepPayload.status attribute to represent invocation success/failure
  • ErrorDetails to provide additional error details in the metadata attribute

This PR also resolves memory leaks in the LangchainCallbackHandler

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

…filerHandler

- Introduced standardized error details capturing in IntermediateStepPayload with ErrorDetails model.
- Updated Context class to emit success or error events based on function execution outcomes, including detailed error metadata.
- Enhanced LangchainProfilerHandler to handle LLM and tool errors, pushing error events with relevant details to the step manager.
- Added EventStatus enumeration to track the status of intermediate steps, improving observability in processing flows.

This ensures proper nesting of spans, event in the event of tool
call/llm/function invocation failures

Signed-off-by: Matthew Penn <mpenn@nvidia.com>
Signed-off-by: Matthew Penn <mpenn@nvidia.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 23, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mpenn mpenn self-assigned this Sep 23, 2025
@mpenn mpenn added bug Something isn't working non-breaking Non-breaking change labels Sep 23, 2025
@willkill07
Copy link
Copy Markdown
Member

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@willkill07 willkill07 added the Stale Activity is stale; may be automatically closed without update label Feb 10, 2026
@github-actions
Copy link
Copy Markdown

This PR was closed because it has been stalled for 14 days with no activity.

@github-actions github-actions Bot closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Non-breaking change Stale Activity is stale; may be automatically closed without update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants