Skip to content

Eliminate duplicate wiki-tool implementations in skill/tools.py#79

Open
wutongyuonce wants to merge 1 commit into
VectifyAI:mainfrom
wutongyuonce:main
Open

Eliminate duplicate wiki-tool implementations in skill/tools.py#79
wutongyuonce wants to merge 1 commit into
VectifyAI:mainfrom
wutongyuonce:main

Conversation

@wutongyuonce
Copy link
Copy Markdown
Contributor

Problem

openkb/skill/tools.py claims to "wrap the canonical wiki tools" from
openkb/agent/tools.py, but two of its five functions were independent
re-implementations
rather than wrappers:

skill/tools.py function agent/tools.py equivalent Status before this PR
list_wiki_dir list_wiki_files Duplicate (identical logic, different variable names)
read_wiki_file_for_skill read_wiki_file Duplicate (identical logic, different variable names)
get_skill_page_content get_wiki_page_content Already delegates
read_skill_image read_wiki_image Already delegates
write_skill_file (no equivalent — genuinely different) Own implementation (correct)

This creates two risks:

  1. Divergence — a bug fix or behavior change applied to one copy can be
    forgotten in the other, creating a "two sources of truth" problem.
  2. False confidence — the module docstring promises "no second
    implementation to drift" while the code contradicts it.

Solution

Replace the bodies of list_wiki_dir and read_wiki_file_for_skill with
single-line delegations to their canonical counterparts in
openkb/agent/tools.py, matching the pattern already established by
get_skill_page_content and read_skill_image.

Changes

1 file changed: openkb/skill/tools.py

  • Imports: added list_wiki_files as _list_wiki_files and
    read_wiki_file as _read_wiki_file from openkb.agent.tools.
  • list_wiki_dir: body replaced with return _list_wiki_files(directory, wiki_root).
  • read_wiki_file_for_skill: body replaced with return _read_wiki_file(path, wiki_root).
  • Module docstring: updated to accurately reflect that all four READ
    functions are now delegated.
  • write_skill_file: unchanged (genuinely different security boundary).

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.

1 participant