fix(langgraph): structured LlmNode outputs with OciGenAiConfig require langchain-oci>=0.3.0 - #250
Open
fede-kamel wants to merge 1 commit into
Open
Conversation
…angchain-oci>=0.3.0 Fixes oracle#232. Loading a Flow whose LlmNode declares structured outputs with an OciGenAiConfig failed at load time with "Unsupported tool type <class 'dict'>. Tool must be passed in as a BaseTool instance, TypedDict class, or BaseModel type." The adapter compiles the node outputs to a JSON schema dict and hands it to `ChatOCIGenAI.with_structured_output`; langchain-oci only started accepting JSON-schema dicts as tool definitions in 0.3.0 (May 2026), but the `langgraph` extra allowed `langchain-oci>=0.2.6`. - setup.py: the `langgraph` extra now requires `langchain-oci>=0.3.0`. - _langgraphconverter: check the installed langchain-oci version before building a ChatOCIGenAI and raise an ImportError that names the minimum version and the upgrade command. - _node_execution: when a chat model rejects the JSON-schema output definition, raise a configuration error naming the LlmNode, the model class and the remedy (upgrade langchain-oci, or declare a single string output) instead of surfacing the provider's low-level error. The original exception is chained. - tests: a legacy-provider fake reproduces the report and asserts the actionable error; ChatOCIGenAI (mocked client) accepts the nested schema and the OCI request carries the `structured_output` function with the nested required fields; the version guard accepts 0.3.x and pre-release tags and rejects 0.2.x. - changelog entry.
fede-kamel
force-pushed
the
fix/langgraph-oci-structured-output-232
branch
from
September 11, 2026 14:36
fb88820 to
b326229
Compare
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.
Fixes #232.
Root cause
The LangGraph adapter compiles an
LlmNode's outputs into a JSON schema dict and passes it towith_structured_output.langchain-ocionly started accepting JSON-schema dicts as tool / structured-output definitions in 0.3.0 (oracle/langchain-oracle#225, May 2026), but thelanggraphextra allowedlangchain-oci>=0.2.6, so environments resolving an older provider failed at load time with the low-levelUnsupported tool type <class 'dict'>error from the report. With langchain-oci 0.3.x the same Flow loads and the OCI request carries the nested schema as a function tool.Changes
setup.py: thelanggraphextra requireslangchain-oci>=0.3.0.ChatOCIGenAI, check the installedlangchain-ociversion and raise anImportErrornaming the minimum and the upgrade command, so an old install fails clearly even outside the extra.LlmNodeExecutor: if the chat model rejects the JSON-schema output definition, raise a configurationValueErrornaming the node, the model class and the two remedies (upgrade langchain-oci, or declare a single string output), with the provider error chained as__cause__. This is option 2 from the issue, kept in addition to the pin so other providers get the same clear message.tests/adapters/langgraph/test_llmnode_structured_output.py): a legacy-provider fake reproduces the report and asserts the actionable error and chained cause;ChatOCIGenAIwith a mocked client accepts the nested schema from the issue and the resulting OCI request carries thestructured_outputfunction withprofile.required == {score, active, tags}(no network); the version guard accepts0.3.2and1.0.0rc1and rejects0.2.7.Verification
New tests: 3 passed. Black, isort clean; mypy on the two package files reports only the pre-existing
langchain_mcp_adaptersimport-not-found in an environment without that optional dependency. The neighbouringtest_bare_llmconfig_dispatch.py/test_disaggregated_config.pyresults are unchanged frommainin my environment.