Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(core): accept fenced JSON in tool call arguments#33012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
TokuiNico wants to merge5 commits intolangchain-ai:master
base:master
Choose a base branch
Loading
fromTokuiNico:fix/core-tool-args-fenced-json

Conversation

TokuiNico
Copy link

@TokuiNicoTokuiNico commentedSep 18, 2025
edited
Loading

Summary

Accept Markdown-fenced JSON in tool call arguments when using with_structured_output. This aligns the structured-output path with the robustness already present in PydanticOutputParser, while keeping strictness for incomplete payloads.

Changes

  • Use parse_json_markdown in parse_tool_call for the non-partial path (no partial fill).
  • Keep strict json.loads under the hood; malformed/incomplete JSON still raises.
  • Add unit tests covering:
    • Normal JSON
    • Fenced JSON
    • Incomplete JSON (expected to error)

Rationale

  • Models may wrap JSON injson ... fences. PydanticOutputParser already tolerates this via parse_json_markdown; with_structured_output should behave similarly so users get consistent parsing across pathways.
  • We deliberately avoid parse_partial_json here to prevent accidentally accepting truncated tool arguments.

Testing

  • All core unit tests pass locally. The new tests specifically verify:
    • Normal JSON parses successfully
    • Fenced JSON parses successfully
    • Incomplete JSON raises OutputParserException

Backwards Compatibility

  • No API changes. For already-valid JSON arguments, behavior is unchanged. This only increases robustness for fenced JSON content.

…re strict parsing\n\n- Use parse_json_markdown in parse_tool_call when partial=False (no partial fill)\n- Keep strict json.loads under the hood; incomplete JSON still errors\n- Add unit tests for normal, fenced, and incomplete JSON cases
@vercelVercel
Copy link

vercelbot commentedSep 18, 2025
edited
Loading

The latest updates on your projects. Learn more aboutVercel for GitHub.

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
langchainIgnoredIgnoredPreviewSep 20, 2025 0:49am

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedSep 18, 2025
edited
Loading

CodSpeed Performance Report

Merging#33012 willdegrade performances by 10.96%

ComparingTokuiNico:fix/core-tool-args-fenced-json (824e63d) withmaster (d0f5a1c)1

⚠️Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend usingCodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

❌ 3 regressions
✅ 10 untouched
⏩ 21 skipped2

⚠️Please fix the performance issues oracknowledge them on CodSpeed.

Benchmarks breakdown

ModeBenchmarkBASEHEADChange
WallTimetest_import_time[BaseChatModel]493.2 ms553.8 ms-10.96%
WallTimetest_import_time[ChatPromptTemplate]561.2 ms626.4 ms-10.41%
WallTimetest_import_time[Runnable]460.9 ms515.3 ms-10.55%

Footnotes

  1. No successful run was found onmaster (c8205ff) during the generation of this report, sod0f5a1c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase,click here and archive them to remove them from the performance reports.

@mdrxymdrxy added the coreRelated to the package `langchain-core` labelSep 20, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@eyurtseveyurtsevAwaiting requested review from eyurtseveyurtsev is a code owner

Assignees

No one assigned

Labels

coreRelated to the package `langchain-core`

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@TokuiNico@mdrxy

[8]ページ先頭

©2009-2025 Movatter.jp