Skip to content

fix: resolve tool duplication and skill parser YAML inconsistencies (#1803)#2107

Merged
WillemJiang merged 20 commits intobytedance:mainfrom
asong56:1803
Apr 20, 2026
Merged

fix: resolve tool duplication and skill parser YAML inconsistencies (#1803)#2107
WillemJiang merged 20 commits intobytedance:mainfrom
asong56:1803

Conversation

@asong56
Copy link
Copy Markdown
Contributor

@asong56 asong56 commented Apr 10, 2026

Description

This PR addresses two root causes of systematic tool failure (name duplication):

  1. Deduplication in 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 like lsls).
  2. YAML Parser Inconsistency: Replaced a custom line-by-line parser in skills/parser.py with yaml.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 .name attribute.

Changes

  • Modified backend/packages/harness/deerflow/tools/tools.py
  • Modified backend/packages/harness/deerflow/skills/parser.py
  • Added backend/tests/test_skills_parser_issue1803.py
  • Added backend/tests/test_tools_deduplication_issue1803.py

Checklist

  • Verified backward compatibility with existing SKILL.md files.
  • Added regression tests for YAML quoting and tool deduplication.

closes #1803

asong56 added 4 commits April 10, 2026 17:30
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.
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

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_load for 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_tool when config.skill_evolution.enabled is 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 the skill_manage tool unless users manually add it to config.tools. Please either restore the conditional append (or otherwise ensure skill_manage_tool is exposed when skill evolution is enabled) and add a regression test around get_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)")

Comment thread backend/tests/test_tool_deduplication.py Outdated
Comment thread backend/tests/test_tool_deduplication.py
Comment thread backend/tests/test_tool_deduplication.py
Comment thread backend/tests/test_skills_parser.py Outdated
WillemJiang and others added 4 commits April 11, 2026 15:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Ensure the test for nonexistent files checks for None.
@asong56
Copy link
Copy Markdown
Contributor Author

asong56 commented Apr 11, 2026

changed test_tool_deduplication.py and test_skills_parser.py

@WillemJiang
Copy link
Copy Markdown
Collaborator

@asong56

skill_manage_tool silently removed (tools.py:64-70 diff)

The PR deletes the conditional inclusion of skill_manage_tool:

  # REMOVED by this PR:
  skill_evolution_config = getattr(config, "skill_evolution", None)
  if getattr(skill_evolution_config, "enabled", False):
      from deerflow.tools.skill_manage_tool import skill_manage_tool
      builtin_tools.append(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.

asong56 added 2 commits April 12, 2026 07:54
Refactor tool loading logic to include skill management tools based on configuration and clean up comments.
@asong56
Copy link
Copy Markdown
Contributor Author

asong56 commented Apr 12, 2026

added back

@WillemJiang
Copy link
Copy Markdown
Collaborator

WillemJiang commented Apr 13, 2026

added back

@asong56, I checked the change. Please keep the comments on the code and fix the lint error.

@WillemJiang WillemJiang added the question Further information is requested label Apr 13, 2026
@asong56
Copy link
Copy Markdown
Contributor Author

asong56 commented Apr 13, 2026

done

@WillemJiang
Copy link
Copy Markdown
Collaborator

@asong56, please use the command to fix the lint error

cd backend
make format

@WillemJiang WillemJiang added the reviewing The PR is in reviewing status label Apr 18, 2026
@asong56
Copy link
Copy Markdown
Contributor Author

asong56 commented Apr 18, 2026

Done

@WillemJiang WillemJiang merged commit 6dce26a into bytedance:main Apr 20, 2026
5 checks passed
@asong56 asong56 deleted the 1803 branch April 20, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested reviewing The PR is in reviewing status

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TOOL INVOCATION BUG REPORT: SYSTEMATIC FUNCTION NAME DUPLICATION

3 participants