Skip to content

[Cherry-Pick][Optimization]Fix tool parser (#7079)#7149

Open
luukunn wants to merge 2 commits intoPaddlePaddle:release/2.4from
luukunn:cherry_pick_2.4
Open

[Cherry-Pick][Optimization]Fix tool parser (#7079)#7149
luukunn wants to merge 2 commits intoPaddlePaddle:release/2.4from
luukunn:cherry_pick_2.4

Conversation

@luukunn
Copy link
Copy Markdown
Collaborator

@luukunn luukunn commented Apr 2, 2026

  • fix tool parser

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

Modifications

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.

Copilot AI review requested due to automatic review settings April 2, 2026 06:40
@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 2, 2026

Thanks for your contribution!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在修复/优化 OpenAI 工具调用(tool call)解析逻辑,主要聚焦于 Ernie X1 的工具解析与流式解析路径,并补充了更大范围的单元测试覆盖。

Changes:

  • 重构 ErnieX1ToolParser.extract_tool_calls:改为通过正则提取 <tool_call>...</tool_call> 并直接 json.loads 解析。
  • 重构 ErnieX1ToolParser.extract_tool_calls_streaming:基于文本计数与 partial_json_parser 的流式增量解析逻辑。
  • 大幅扩充 test_ernie_x1_tool_parser.py 的用例覆盖;并在 ernie_45_vl_thinking_tool_parser.py 移除对空 chunk 的显式跳过逻辑。

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
fastdeploy/entrypoints/openai/tool_parsers/ernie_x1_tool_parser.py 重构 Ernie X1 的非流式/流式工具解析实现,并调整日志与解析策略。
tests/entrypoints/openai/tool_parsers/test_ernie_x1_tool_parser.py 补充大量针对 Ernie X1 工具解析的单测覆盖与分支覆盖。
fastdeploy/entrypoints/openai/tool_parsers/ernie_45_vl_thinking_tool_parser.py 移除流式解析中对空白 chunk 的提前 return。

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.47826% with 9 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/2.4@57b97d3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...points/openai/tool_parsers/ernie_x1_tool_parser.py 93.47% 5 Missing and 4 partials ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.4    #7149   +/-   ##
==============================================
  Coverage               ?   56.46%           
==============================================
  Files                  ?      333           
  Lines                  ?    42615           
  Branches               ?     6477           
==============================================
  Hits                   ?    24061           
  Misses                 ?    16683           
  Partials               ?     1871           
Flag Coverage Δ
GPU 56.46% <93.47%> (?)

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.

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.

3 participants