Skip to content

🐛 Bugfix: Add display name to index name mapping for KnowledgeBaseSearchTool#2781

Merged
WMC001 merged 3 commits intodevelopfrom
develop_fix_kb_3
Apr 25, 2026
Merged

🐛 Bugfix: Add display name to index name mapping for KnowledgeBaseSearchTool#2781
WMC001 merged 3 commits intodevelopfrom
develop_fix_kb_3

Conversation

@Zhi-a
Copy link
Copy Markdown
Contributor

@Zhi-a Zhi-a commented Apr 15, 2026

#2803

  • Introduced get_knowledge_name_map_by_index_names function to retrieve a mapping of index names to their corresponding display names.
  • Updated create_agent_config and create_tool_config_list to utilize the new mapping for generating user-friendly summaries.
  • Enhanced KnowledgeBaseSearchTool to support conversion from display names to index names during queries.
  • Added tests to verify the functionality of the new mapping and its integration within the tool configuration process.
2026-04-17_09-04-45.mp4
image

- Introduced `get_knowledge_name_map_by_index_names` function to retrieve a mapping of index names to their corresponding display names.
- Updated `create_agent_config` and `create_tool_config_list` to utilize the new mapping for generating user-friendly summaries.
- Enhanced `KnowledgeBaseSearchTool` to support conversion from display names to index names during queries.
- Added tests to verify the functionality of the new mapping and its integration within the tool configuration process.
Copilot AI review requested due to automatic review settings April 15, 2026 07:09
@Zhi-a Zhi-a requested review from Phinease and WMC001 as code owners April 15, 2026 07:09
Comment thread test/backend/agents/test_create_agent_info.py Fixed
Comment thread test/backend/agents/test_create_agent_info.py Fixed
Comment thread test/backend/agents/test_create_agent_info.py Fixed
Comment thread test/backend/agents/test_create_agent_info.py Fixed
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

Adds a display-name ↔ index-name mapping flow for knowledge bases so prompts can show user-friendly KB names while the search tool still queries by internal index names.

Changes:

  • Introduces get_knowledge_name_map_by_index_names() (index_name → knowledge_name) and uses it to render KB summaries with display names.
  • Propagates a reversed display_name_to_index_map (knowledge_name → index_name) into KnowledgeBaseSearchTool configs and local tool instantiation.
  • Updates KnowledgeBaseSearchTool to convert index_names passed by the LLM from display names to internal index names; adds/updates tests across backend+sdk.

Reviewed changes

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

Show a summary per file
File Description
sdk/nexent/core/tools/knowledge_base_search_tool.py Adds display_name_to_index_map and _convert_to_index_names() used by forward() to translate display names into index names.
backend/agents/create_agent_info.py Uses index→display mapping to render KB summaries with display names; injects display→index mapping into tool metadata.
backend/database/knowledge_db.py Adds get_knowledge_name_map_by_index_names() to fetch index→display mapping with fallback behavior.
backend/services/tool_configuration_service.py Adds mapping generation during local tool validation so KB tool can accept display names.
sdk/nexent/core/agents/nexent_agent.py Ensures display_name_to_index_map is set post-instantiation for KnowledgeBaseSearchTool.
test/sdk/core/tools/test_knowledge_base_search_tool.py Extends tests for conversion behavior and related KBSearch behaviors.
test/sdk/core/agents/test_nexent_agent.py Adds tests validating metadata injection of display_name_to_index_map for local tool creation.
test/backend/services/test_tool_configuration_service.py Updates mocks/patching and adds coverage for mapping injection during local tool validation.
test/backend/database/test_knowledge_db.py Adds unit tests for get_knowledge_name_map_by_index_names() including fallback and error paths.
test/backend/agents/test_create_agent_info.py Updates/extends tests to expect the new mapping behavior in tool metadata and agent config generation.
Comments suppressed due to low confidence (1)

backend/services/tool_configuration_service.py:46

  • This import block now contains duplicate imports (e.g., minio_client is imported twice and get_embedding_model/get_vector_db_core are imported twice). Please deduplicate/merge these imports to avoid confusion and keep the module tidy.
from database.knowledge_db import get_knowledge_name_map_by_index_names
from mcpadapt.smolagents_adapter import _sanitize_function_name
from services.file_management_service import get_llm_model
from services.vectordatabase_service import get_embedding_model, get_rerank_model, get_vector_db_core
from database.client import minio_client
from services.image_service import get_vlm_model
from services.vectordatabase_service import get_embedding_model, get_vector_db_core
from utils.langchain_utils import discover_langchain_modules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/sdk/core/tools/test_knowledge_base_search_tool.py
Comment thread sdk/nexent/core/tools/knowledge_base_search_tool.py Outdated
Comment thread backend/agents/create_agent_info.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 98.24561% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/database/knowledge_db.py 93.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…into develop_fix_kb_3

# Conflicts:
#	test/backend/agents/test_create_agent_info.py
@Zhi-a Zhi-a requested a review from Dallas98 as a code owner April 21, 2026 06:14
@Zhi-a Zhi-a changed the title ✨ Add display name to index name mapping for KnowledgeBaseSearchTool 🐛 Bugfix: Add display name to index name mapping for KnowledgeBaseSearchTool Apr 25, 2026
@WMC001 WMC001 merged commit 7890cde into develop Apr 25, 2026
12 of 13 checks passed
@Zhi-a Zhi-a deleted the develop_fix_kb_3 branch April 28, 2026 07:07
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