Skip to content

(Openinference Migration: Langchain) Add support for legacy OpenAI function call (PR #2)#281

Open
rads-1996 wants to merge 4 commits into
open-telemetry:mainfrom
rads-1996:langchain-legacy-function-call
Open

(Openinference Migration: Langchain) Add support for legacy OpenAI function call (PR #2)#281
rads-1996 wants to merge 4 commits into
open-telemetry:mainfrom
rads-1996:langchain-legacy-function-call

Conversation

@rads-1996

@rads-1996 rads-1996 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description

Part of #272

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. List any relevant details for your test
configuration.

  • uv run tox -e py312-test-instrumentation-genai-langchain -- -q
  • uv run tox -e py312-test-instrumentation-genai-langchain-conformance -- -q
  • uv run --python 3.12 tox -e lint-instrumentation-genai-langchain

Checklist

See CONTRIBUTING.md
for the style guide, changelog guidance, and more.

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

@rads-1996 rads-1996 changed the title (Openinference Migration: Langchain) Add support for Langchain legacy function call (PR #2) (Openinference Migration: Langchain) Add support for legacy OpenAI function call (PR #2) Jul 17, 2026
@rads-1996
rads-1996 force-pushed the langchain-legacy-function-call branch from f7335e3 to ce0567b Compare July 17, 2026 20:28
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 18, 2026

Copy link
Copy Markdown

Pull request dashboard status

Status last refreshed: 2026-07-25 18:45:09 UTC.

  • Waiting on: Reviewers
  • Next step: Review the latest changes.

This automated status or its linked feedback items may be incorrect. If something looks wrong, please report it with the result you expected.

@rads-1996
rads-1996 force-pushed the langchain-legacy-function-call branch 2 times, most recently from cef69c2 to 5e5a3f8 Compare July 21, 2026 20:00
@rads-1996
rads-1996 marked this pull request as ready for review July 21, 2026 20:04
@rads-1996
rads-1996 requested a review from a team as a code owner July 21, 2026 20:04
Copilot AI review requested due to automatic review settings July 21, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support in the LangChain GenAI instrumentation for legacy (pre-tool_calls) OpenAI additional_kwargs["function_call"] so it surfaces as a ToolCallRequest in both input and output message models, aligning behavior with the modern tool_calls path.

Changes:

  • Added _legacy_function_call_request() helper to parse additional_kwargs["function_call"] (including JSON-string arguments) into a ToolCallRequest.
  • Extended both _ai_message_parts() (input path) and on_llm_end() (output path) to emit the legacy function call as a tool-call request part.
  • Added unit tests covering dict/string arguments, absence behavior, and end-to-end callback handler output message behavior; added a towncrier changelog fragment.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
instrumentation/opentelemetry-instrumentation-genai-langchain/tests/test_callback_handler.py Adds regression/unit tests validating legacy function_call is converted into ToolCallRequest in input/output message modeling.
instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/utils.py Implements legacy function_call extraction and wires it into AI message part construction.
instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/callback_handler.py Emits legacy function_call as an output tool-call request part during on_llm_end.
instrumentation/opentelemetry-instrumentation-genai-langchain/.changelog/281.added Documents the added legacy function_call capture support.

@rads-1996
rads-1996 force-pushed the langchain-legacy-function-call branch 2 times, most recently from 310a63f to c7c6b07 Compare July 22, 2026 15:11
Surface pre-tools OpenAI `additional_kwargs['function_call']` as a ToolCallRequest in both input and output messages, matching the modern tool_calls path.
@rads-1996
rads-1996 force-pushed the langchain-legacy-function-call branch from c7c6b07 to b289022 Compare July 23, 2026 21:44
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.

2 participants