Skip to content

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

Merged
dhilloulinoracle merged 3 commits into
oracle:mainfrom
fede-kamel:fix/langgraph-oci-structured-output-232
Oct 1, 2026
Merged

dhilloulinoracle merged 3 commits into
oracle:mainfrom
fede-kamel:fix/langgraph-oci-structured-output-232

Conversation

@fede-kamel

@fede-kamel fede-kamel commented Sep 11, 2026 •

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-full 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-full extra requires langchain-oci>=0.3.0.
  • constraints/constraints.txt, constraints_dev.txt, constraints_v26.3.1.txt: pin langchain-oci==0.3.2 (was 0.2.6).
  • 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).
  • Changelog entry under Bug fixes.

Per review, the runtime langchain-oci version check originally proposed in the converter was dropped in favour of the dependency bump alone.

Verification

New tests: 2 passed. tests/adapters/langgraph passes with the langgraph-full extra installed under the updated constraints (langchain-oci 0.3.2). Black, isort and git diff --check clean. Rebased on current main.

Comment thread pyagentspec/setup.py
Comment thread pyagentspec/src/pyagentspec/adapters/langgraph/_langgraphconverter.py Outdated
fede-kamel added a commit to fede-kamel/agent-spec that referenced this pull request Sep 30, 2026
…ersion guard

Review feedback on oracle#250: the dependency bump in setup.py is enough, so the
_check_langchain_oci_version helper, its call site and its test are removed.
The three constraints files now pin langchain-oci==0.3.2 to match the
langchain-oci>=0.3.0 requirement of the langgraph-full extra, and the
changelog entry names the langgraph-full extra.
@fede-kamel
fede-kamel force-pushed the fix/langgraph-oci-structured-output-232 branch from b326229 to 5d5f63d Compare September 30, 2026 17:16
@dhilloulinoracle

Copy link
Copy Markdown
Contributor

Internal regression succeeded 🍏: Build ID #584

Comment thread pyagentspec/constraints/constraints_v26.3.1.txt Outdated
…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.
…ersion guard

Review feedback on oracle#250: the dependency bump in setup.py is enough, so the
_check_langchain_oci_version helper, its call site and its test are removed.
The three constraints files now pin langchain-oci==0.3.2 to match the
langchain-oci>=0.3.0 requirement of the langgraph-full extra, and the
changelog entry names the langgraph-full extra.
constraints_v26.3.1.txt records the dependency versions of the published
26.3.1 release and must not move with a bug fix. The langchain-oci 0.3.2
pin stays in constraints.txt and constraints_dev.txt.
@cesarebernardis
cesarebernardis force-pushed the fix/langgraph-oci-structured-output-232 branch from f9ada8e to fd315f2 Compare October 1, 2026 16:47
@dhilloulinoracle

Copy link
Copy Markdown
Contributor

Merge Gate INPROGRESS

@dhilloulinoracle

Copy link
Copy Markdown
Contributor

Internal regression succeeded 🍏: Build ID #525

@dhilloulinoracle
dhilloulinoracle merged commit 585b751 into oracle:main Oct 1, 2026
6 of 7 checks passed
@dhilloulinoracle

Copy link
Copy Markdown
Contributor

Merge Gate succeeded 🍏: Build ID #753

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

4 participants