Skip to content

✨ Feature: Recommend and prefill bound NL2Agent tools - #3783

Open
RedShakespeare wants to merge 5 commits into
developfrom
dyx/nl2a-kb
Open

✨ Feature: Recommend and prefill bound NL2Agent tools#3783
RedShakespeare wants to merge 5 commits into
developfrom
dyx/nl2a-kb

Conversation

@RedShakespeare

@RedShakespeare RedShakespeare commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Enable NL2Agent to recommend already-bound Tools again and restore their current configuration in the installed-resource binding card.

This change also exposes knowledge_base_search specifically to NL2Agent resource discovery and requires users to select an accessible knowledge base before confirming the binding.

What changed

Support knowledge base search in NL2Agent

  • Allow knowledge_base_search to participate in NL2Agent installed-resource search even though it is not globally user-selectable.
  • Keep other non-selectable Tools, including aidp_search, hidden.
  • Normalize index_names as a required array configuration field.
  • Reuse the existing knowledge base selector and configuration flow.
  • Keep knowledge_base_search out of the ordinary Tool binding list on the right side.
  • Open and focus the Knowledge Base section after binding this Tool.

Re-recommend already-bound Tools

  • Treat already-bound Tools as normal search candidates.
  • Preserve their original search scores and apply the same coverage rules.
  • Allow both ordinary Tools and knowledge_base_search to be recommended again.
  • Update the existing binding after confirmation instead of creating a duplicate.

Restore existing configuration

  • Load the current draft configuration before enabling card interaction.
  • Merge existing Tool parameter values into the latest configuration schema.
  • Prefill previously selected knowledge bases for knowledge_base_search.
  • Filter out knowledge bases that are no longer accessible.
  • Require explicit confirmation when saved knowledge bases have become inaccessible.
  • Prevent binding when no required knowledge base is selected.
  • Provide loading, failure, and retry states for configuration hydration.

Update NL2Agent orchestration

  • Update the English and Chinese prompts to keep already-bound Tools eligible for recommendation.
  • Clarify that bound Tools must not be discarded solely because they appear in bound_resources.
  • Restore configuration in the browser instead of adding configuration values to the model recommendation context.

Why

NL2Agent previously hid knowledge_base_search and could discard Tools that were already bound to the Agent. Users therefore could not reliably add knowledge base retrieval through the conversation or review and update an existing Tool configuration.

This change lets users confirm or revise existing bindings while preserving the distinction between the dedicated Knowledge Base configuration and the ordinary Tool list.

Impact

  • NL2Agent can discover and recommend knowledge_base_search.
  • Knowledge base selection is required before the Tool can be bound.
  • Already-bound ordinary Tools and knowledge base Tools can be recommended again with their current configuration prefilled.
  • Inaccessible knowledge base selections are removed before confirmation.
  • Global Tool selectability remains unchanged.
  • No database migration is introduced.

Validation

  • Added backend unit coverage for the NL2Agent-only visibility exception.
  • Added coverage confirming other hidden Tools remain excluded.
  • Added coverage for required index_names normalization and knowledge base search discovery.
  • Added bilingual prompt contract coverage for repeated recommendations.
  • Focused backend tests passed: 19 passed.
  • git diff --check passed.
  • Frontend tests and builds were not run in this workspace as requested.

Known limitations

  • Knowledge base availability still depends on the current user's tenant permissions.
  • No authenticated browser end-to-end test was run for the complete recommendation and binding workflow.

Screenshots

5c56ee05-5135-4f16-964c-0ab051702d36 b10636ca-a7ca-4e79-9162-862ddf38025e

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread backend/services/nl2agent_service.py Outdated
Comment thread backend/services/nl2agent_service.py
Comment thread backend/services/nl2agent_service.py Outdated
Comment on lines +396 to +425
def _normalize_nl2agent_tool_config(
*,
tool_name: str,
params: Any,
) -> list[dict[str, Any]]:
config = _normalize_tool_config(params)
if tool_name != "knowledge_base_search":
return config

index_names = next(
(param for param in config if param["name"] == "index_names"),
None,
)
if index_names is None:
config.append(
{
"name": "index_names",
"type": "array",
"required": True,
"value": [],
"description": "The list of index names to search",
"description_zh": "要索引的知识库",
}
)
else:
index_names["type"] = "array"
index_names["required"] = True
if not isinstance(index_names.get("value"), list):
index_names["value"] = []
return config

@xuyaqist xuyaqist Aug 26, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

为什么这里要单独判断?这个工具和其他工具没有区别,用户选择某个知识库=用户向input框里填入一些参数,无论对于哪个工具,对params的操作都是一样的?

@xuyaqist

Copy link
Copy Markdown
Contributor

效果要求:如果用户预先自己已经绑定一些tool,然后在nl2agent的过程中,推荐工具的时候,要知道哪些已经绑定过,要有个已绑定的标识。并且点击配置的时候,能够看到之前用户绑定工具的配置,用户可以修改。数据库始终只有一条数据。

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.

2 participants