Skip to content

fix: preserve provider tool call metadata in OpenAI chat completions - #121

Merged
andreitava-uip merged 3 commits into
mainfrom
fix/openai-tool-call-metadata
Aug 6, 2026
Merged

fix: preserve provider tool call metadata in OpenAI chat completions#121
andreitava-uip merged 3 commits into
mainfrom
fix/openai-tool-call-metadata

Conversation

@andreitava-uip

@andreitava-uip andreitava-uip commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Why

BYOM models exposed through an OpenAI V1-compatible Chat Completions API may return provider-specific tool-call metadata that must be included in subsequent requests. The client currently loses these fields when converting responses into LangChain messages, causing multi-turn tool execution to fail for providers that require the original metadata.

Summary

  • preserve provider-specific top-level fields when parsing OpenAI-compatible tool calls
  • restore preserved fields when sending subsequent Chat Completions requests
  • keep updated function arguments authoritative while retaining opaque provider metadata
  • support non-streaming, streaming, and multiple tool calls

Testing

  • uv run pytest tests/langchain/clients/openai/test_tool_call_extras.py -q
  • uv run ruff check
  • uv run ruff format --check
  • uv run pyright .

@andreitava-uip
andreitava-uip merged commit 1e77dc2 into main Aug 6, 2026
12 checks passed
@andreitava-uip
andreitava-uip deleted the fix/openai-tool-call-metadata branch August 6, 2026 14:56
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