fix: resolve tool duplication and skill parser YAML inconsistencies (#1803)#2107
fix: resolve tool duplication and skill parser YAML inconsistencies (#1803)#2107WillemJiang merged 20 commits intobytedance:mainfrom
Conversation
Updated tests for SKILL.md parser to handle quoted names and descriptions correctly. Added new tests for parsing plain and single-quoted names, and ensured multi-line descriptions are processed properly.
Add tool name mismatch warning and deduplication logic
Added tests for tool name deduplication in get_available_tools(). Ensured that duplicates are not returned, the first occurrence is kept, and warnings are logged for skipped duplicates.
There was a problem hiding this comment.
Pull request overview
This PR fixes two root causes behind systematic tool invocation failures in DeerFlow: duplicate tool registrations (leading to ambiguous tool schemas) and inconsistent YAML parsing between SKILL.md parsing vs validation.
Changes:
- Added name-based, first-occurrence-wins deduplication to
get_available_tools(), with warnings for duplicates and for config-name vs tool-name mismatches. - Replaced the hand-rolled SKILL.md front-matter parser with
yaml.safe_loadfor consistent YAML semantics (quoting, multiline, etc.). - Added/updated regression tests covering tool deduplication and YAML front-matter parsing edge cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
backend/packages/harness/deerflow/tools/tools.py |
Adds tool-name mismatch warning + name-based deduplication of the final tool list returned to the agent/runtime. |
backend/packages/harness/deerflow/skills/parser.py |
Switches SKILL.md front-matter parsing to yaml.safe_load and tightens type/emptiness checks for required fields. |
backend/tests/test_tool_deduplication.py |
New regression tests to ensure get_available_tools() never returns duplicate tool names and logs warnings on duplicates. |
backend/tests/test_skills_parser.py |
Updates tests to specifically cover the quoted-string YAML regression and related parser behaviors. |
Comments suppressed due to low confidence (1)
backend/packages/harness/deerflow/tools/tools.py:87
- The conditional inclusion of
skill_manage_toolwhenconfig.skill_evolution.enabledis true was removed. If skill self-evolution is still supported, this change likely prevents the agent from ever being able to create/patch skills via theskill_managetool unless users manually add it toconfig.tools. Please either restore the conditional append (or otherwise ensureskill_manage_toolis exposed when skill evolution is enabled) and add a regression test aroundget_available_tools()for this behavior.
# Conditionally add tools based on config
builtin_tools = BUILTIN_TOOLS.copy()
# Add subagent tools only if enabled via runtime parameter
if subagent_enabled:
builtin_tools.extend(SUBAGENT_TOOLS)
logger.info("Including subagent tools (task)")
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Ensure the test for nonexistent files checks for None.
|
changed test_tool_deduplication.py and test_skills_parser.py |
|
skill_manage_tool silently removed (tools.py:64-70 diff) The PR deletes the conditional inclusion of skill_manage_tool: This means skill self-evolution (the ability for the agent to create/patch skills via the skill_manage tool) is completely broken when skill_evolution.enabled = true in config. The tool simply won't appear in the agent's toolset. Fix: Restore the conditional block. It should come after the BUILTIN_TOOLS.copy() line and before the deduplication logic. |
Refactor tool loading logic to include skill management tools based on configuration and clean up comments.
|
added back |
Added comments to clarify the purpose of various code sections related to tool loading and configuration.
|
done |
|
@asong56, please use the command to fix the lint error |
|
Done |
Description
This PR addresses two root causes of systematic tool failure (name duplication):
get_available_tools: Added a "first-occurrence-wins" deduplication step to prevent the LLM from receiving multiple schemas for the same tool (which caused name concatenation likelsls).skills/parser.pywithyaml.safe_load. The previous custom parser incorrectly handled quoted strings and ignored list values, leading to registration mismatches.Additionally, added a warning for cases where a tool's config name differs from its decorated
.nameattribute.Changes
backend/packages/harness/deerflow/tools/tools.pybackend/packages/harness/deerflow/skills/parser.pybackend/tests/test_skills_parser_issue1803.pybackend/tests/test_tools_deduplication_issue1803.pyChecklist
closes #1803