Skip to content

[Cherry-Pick][BugFix] fix tool call parser(#7369)#7419

Merged
Jiang-Jia-Jun merged 1 commit intoPaddlePaddle:release/2.6from
EmmonsCurse:cherry-pick/7369/release/2.6
Apr 16, 2026
Merged

[Cherry-Pick][BugFix] fix tool call parser(#7369)#7419
Jiang-Jia-Jun merged 1 commit intoPaddlePaddle:release/2.6from
EmmonsCurse:cherry-pick/7369/release/2.6

Conversation

@EmmonsCurse
Copy link
Copy Markdown
Collaborator

Cherry-pick of #7369 (authored by @luukunn) to release/2.6.

devPR:#7369


Motivation

  • 修复 extract_tool_callstools_calledtool_calls 为空时仍返回 True 的问题
  • 修复空字典 {} 被误判为无参数的问题
  • 修复流式输出结束处理中 '"}' 检查过于严格导致数字/布尔值结尾的参数无法正确流式传输的问题

Modifications

  • tools_called=True 改为 tools_called=len(tool_calls) > 0
  • if diff: 改为 if diff is not None:,正确处理空字典
  • if '"}' not in delta_text: 改为 if "}" not in delta_text:,并使用 rindex("}") 获取正确位置
  • 将所有 if not cur_arguments 改为 if cur_arguments is None,避免空字典误判
  • 新增回归测试覆盖空参数、数字/布尔值结尾参数、嵌套对象等边界情况

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
  • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
  • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

* fix tool call parser

* add unit test

* fix unit test

* add unit test
@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 15, 2026

Thanks for your contribution!

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/2.6@2ee1cc3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...points/openai/tool_parsers/ernie_x1_tool_parser.py 77.77% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.6    #7419   +/-   ##
==============================================
  Coverage               ?   73.90%           
==============================================
  Files                  ?      376           
  Lines                  ?    52982           
  Branches               ?     8275           
==============================================
  Hits                   ?    39156           
  Misses                 ?    11081           
  Partials               ?     2745           
Flag Coverage Δ
GPU 73.90% <77.77%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Jiang-Jia-Jun Jiang-Jia-Jun merged commit 72ce56b into PaddlePaddle:release/2.6 Apr 16, 2026
34 of 37 checks passed
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.

4 participants