Skip to content

fix(langgraph): structured LlmNode outputs with OciGenAiConfig require langchain-oci>=0.3.0 - #250

Open
fede-kamel wants to merge 1 commit into
oracle:mainfrom
fede-kamel:fix/langgraph-oci-structured-output-232
Open

fix(langgraph): structured LlmNode outputs with OciGenAiConfig require langchain-oci>=0.3.0#250
fede-kamel wants to merge 1 commit into
oracle:mainfrom
fede-kamel:fix/langgraph-oci-structured-output-232

Conversation

@fede-kamel

Copy link
Copy Markdown
Member

Fixes #232.

Root cause

The LangGraph adapter compiles an LlmNode's outputs into a JSON schema dict and passes it to with_structured_output. langchain-oci only started accepting JSON-schema dicts as tool / structured-output definitions in 0.3.0 (oracle/langchain-oracle#225, May 2026), but the langgraph extra allowed langchain-oci>=0.2.6, so environments resolving an older provider failed at load time with the low-level Unsupported 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: the langgraph extra requires langchain-oci>=0.3.0.
  • Converter: before constructing ChatOCIGenAI, check the installed langchain-oci version and raise an ImportError naming 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 configuration ValueError naming 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 (tests/adapters/langgraph/test_llmnode_structured_output.py): a legacy-provider fake reproduces the report and asserts the actionable error and chained cause; ChatOCIGenAI with a mocked client accepts the nested schema from the issue and the resulting OCI request carries the structured_output function with profile.required == {score, active, tags} (no network); the version guard accepts 0.3.2 and 1.0.0rc1 and rejects 0.2.7.
  • Changelog entry under Bug fixes.

Verification

New tests: 3 passed. Black, isort clean; mypy on the two package files reports only the pre-existing langchain_mcp_adapters import-not-found in an environment without that optional dependency. The neighbouring test_bare_llmconfig_dispatch.py / test_disaggregated_config.py results are unchanged from main in my environment.

@fede-kamel
fede-kamel requested a review from a team September 11, 2026 14:20
@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Sep 11, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LangGraph adapter fails to load OciGenAiConfig LlmNode with structured output

1 participant