Skip to content

fix(genai): guard cached_content with tools#1530

Open
Junaid Ahmad (junaidaslam2006) wants to merge 17 commits intolangchain-ai:mainfrom
junaidaslam2006:fix/genai-output-version-content
Open

fix(genai): guard cached_content with tools#1530
Junaid Ahmad (junaidaslam2006) wants to merge 17 commits intolangchain-ai:mainfrom
junaidaslam2006:fix/genai-output-version-content

Conversation

@junaidaslam2006
Copy link
Contributor

@junaidaslam2006 Junaid Ahmad (junaidaslam2006) commented Jan 21, 2026

Summary

  • Preserve list-based content: Updated for Gemini 3 and output version v1 to prevent content from collapsing into strings.
  • Propagate output_version: Handled via response parsing/metadata without sending it to the request config.
  • API Constraint Guard: Prevent cached_content from being combined with tools, tool_config, or system_instruction to comply with Gemini API requirements.

Fixes #1528

Testing

I have verified the fix using the following integration tests:

pytest libs/genai/tests/integration_tests/test_chat_models.py::test_search_builtin
pytest libs/genai/tests/integration_tests/test_chat_models.py::test_structured_output_with_google_search
pytest libs/genai/tests/integration_tests/test_chat_models.py::test_gemini_3_pro_agent_loop_streaming
pytest libs/genai/tests/integration_tests/test_standard.py::TestGeminiProStandardGoogleAI::test_structured_output_optional_param

@junaidaslam2006 Junaid Ahmad (junaidaslam2006) changed the title Preserve v1/Gemini 3 content blocks and propagate output_version fix(genai): preserve v1/Gemini 3 content blocks Jan 21, 2026
@junaidaslam2006 Junaid Ahmad (junaidaslam2006) changed the title fix(genai): preserve v1/Gemini 3 content blocks fix(genai): guard cached_content with tools Jan 21, 2026
@junaidaslam2006
Copy link
Contributor Author

Junaid Ahmad (junaidaslam2006) commented Jan 22, 2026

llm test is failing
can any maintainer rerun and share last test name

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.

Gemini Context Caching Incompatibility with LangChain Tools/Agents

1 participant