feat(genai,vertexai): expose provider response ids#1772
Open
Ayush Srivastava (luigivendetta) wants to merge 6 commits into
Open
feat(genai,vertexai): expose provider response ids#1772Ayush Srivastava (luigivendetta) wants to merge 6 commits into
Ayush Srivastava (luigivendetta) wants to merge 6 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Expose Google's provider response identifier as
AIMessage.response_metadata["id"]for bothlangchain-google-genaiandlangchain-google-vertexai.This lets users correlate LangChain responses with Gemini and Vertex dashboards/logs without storing prompt or response text. The metadata key matches
langchain-openai, which already exposes the native provider response ID throughresponse_metadata["id"].This intentionally stores the provider ID in
response_metadata, notmessage.id, so it remains additive and does not change LangChain message identity behavior.Relevant issues
N/A
Type
🆕 New Feature
✅ Test
Changes
GenerateContentResponse.response_id.response_id/responseId.message.id,additional_kwargs, content parsing, thinking blocks, tool-call IDs, and usage metadata behavior.Why this approach
response_metadata["id"]for provider parity withlangchain-openai.Review notes
Areas worth extra review:
response_metadata["id"]is the preferred cross-provider key.Testing
Passed locally:
cd libs/genai && UV_CACHE_DIR=/tmp/uv-cache uv lock --checkcd libs/genai && UV_CACHE_DIR=/tmp/uv-cache make lint_packagecd libs/genai && UV_CACHE_DIR=/tmp/uv-cache make lint_testscd libs/genai && UV_CACHE_DIR=/tmp/uv-cache make test TEST_FILE=tests/unit_tests/test_chat_models.py217 passedcd libs/genai && UV_CACHE_DIR=/tmp/uv-cache uv run --group test --group test_integration pytest -m compile tests/integration_testscd libs/vertexai && UV_CACHE_DIR=/tmp/uv-cache uv lock --checkcd libs/vertexai && UV_CACHE_DIR=/tmp/uv-cache make lint_packagecd libs/vertexai && UV_CACHE_DIR=/tmp/uv-cache make lint_testscd libs/vertexai && UV_CACHE_DIR=/tmp/uv-cache make test TEST_FILE=tests/unit_tests/test_chat_models.py110 passed, 1 skippedcd libs/vertexai && UV_CACHE_DIR=/tmp/uv-cache uv run --group test --group test_integration pytest -m compile tests/integration_testsNote
This touches both GenAI and Vertex intentionally so provider response ID metadata lands consistently across Google chat integrations. I can split this into separate package PRs if that is easier to review.
This contribution was prepared with assistance from AI agents. The author reviewed and validated the changes locally.