Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/agents/create_agent_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,9 @@ async def create_tool_config_list(
"api_key": AIDP_API_KEY,
"tenant_id": AIDP_TENANT_ID,
})
param_dict.pop("server_url", None)
param_dict.pop("api_key", None)
param_dict.pop("tenant_id", None)

# v7.1: inject the runtime whitelist for AidpSearchTool. The
# permission service recomputes it on every agent call so per-KB
Expand Down Expand Up @@ -1471,7 +1474,7 @@ async def create_tool_config_list(
existing = tool_config.metadata if isinstance(tool_config.metadata, dict) else {}
tool_config.metadata = {
**existing,
"allowed_kds_set": _allowed_kds_set,
"allowed_kds_set": list(_allowed_kds_set),
"kds_name_to_id_map": _kds_name_to_id_map,
}
tool_class_name = tool.get("class_name")
Expand Down
4 changes: 4 additions & 0 deletions sdk/nexent/core/agents/nexent_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import inspect
import json
import logging
import os
import re
import time
from dataclasses import replace
Expand Down Expand Up @@ -351,6 +352,9 @@ def create_local_tool(self, tool_config: ToolConfig):
# kds_name_to_id_map is exclude=True; inject via metadata after init
filtered_params = {k: v for k, v in params.items()
if k not in ["kds_name_to_id_map"]}
filtered_params["server_url"] = os.getenv("AIDP_SERVER_URL", "")
filtered_params["api_key"] = os.getenv("AIDP_API_KEY", "")
filtered_params["tenant_id"] = os.getenv("AIDP_TENANT_ID", "aidp")
tools_obj = tool_class(**filtered_params)
tools_obj.observer = self.observer
tools_obj.kds_name_to_id_map = tool_config.metadata.get(
Expand Down
13 changes: 7 additions & 6 deletions test/backend/agents/test_create_agent_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7179,10 +7179,11 @@ def capture_and_return(**kwargs):
)

assert len(result) == 1
# Verify env creds are in the params (overriding stale DB values)
assert mock_tc_instance.params["server_url"] == "https://aidp.test"
assert mock_tc_instance.params["api_key"] == "key-123"
assert mock_tc_instance.params["tenant_id"] == "aidp-tenant"
# Verify env creds were injected then removed from params
# (runtime params are handled by nexent_agent.py at tool creation time)
assert "server_url" not in mock_tc_instance.params
assert "api_key" not in mock_tc_instance.params
assert "tenant_id" not in mock_tc_instance.params

@pytest.mark.asyncio
async def test_aidp_search_permission_whitelist_success(self):
Expand Down Expand Up @@ -7235,7 +7236,7 @@ def capture_and_return(**kwargs):
assert len(result) == 1
assert mock_tc_instance.metadata is not None
assert "allowed_kds_set" in mock_tc_instance.metadata
assert mock_tc_instance.metadata["allowed_kds_set"] == {"kb_allowed_1", "kb_allowed_2"}
assert set(mock_tc_instance.metadata["allowed_kds_set"]) == {"kb_allowed_1", "kb_allowed_2"}

@pytest.mark.asyncio
async def test_aidp_search_permission_whitelist_failure_fallback(self):
Expand Down Expand Up @@ -7288,7 +7289,7 @@ def capture_and_return(**kwargs):
assert len(result) == 1
# allowed_kds_set should be empty set on failure
assert mock_tc_instance.metadata is not None
assert mock_tc_instance.metadata["allowed_kds_set"] == set()
assert mock_tc_instance.metadata["allowed_kds_set"] == []

@pytest.mark.asyncio
async def test_aidp_search_metadata_merges_langchain_tool(self):
Expand Down
7 changes: 6 additions & 1 deletion test/sdk/core/agents/test_nexent_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5125,7 +5125,12 @@ def test_aidp_search_tool_with_allowed_kds_set(self, nexent_agent_instance):
del nexent_agent.__dict__["AidpSearchTool"]

assert result is mock_tool_instance
mock_tool_class.assert_called_once_with(param1="val")
mock_tool_class.assert_called_once_with(
param1="val",
server_url="",
api_key="",
tenant_id="aidp",
)
mock_tool_instance.set_allowed_kds.assert_called_once_with(["kb1", "kb2"])
assert mock_tool_instance.observer == nexent_agent_instance.observer

Expand Down
Loading