Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d0aad14
修改单元测试
xuyaqist May 19, 2026
ddda2c4
Revert "修改单元测试"
xuyaqist May 19, 2026
be7299d
Merge branch 'develop' into xyq/refactor_agent_page
xuyaqist May 20, 2026
af7d130
Merge branch 'develop' into xyq/refactor_agent_page
xuyaqist May 21, 2026
149de8e
Merge branch 'develop' into xyq/refactor_agent_page
xuyaqist May 21, 2026
7d936d4
Optimize agent page layout
xuyaqist May 25, 2026
cdadf61
Refactor agent generate page
xuyaqist May 25, 2026
091cd27
Merge branch 'develop' into xyq/refactor_agent_page
xuyaqist May 25, 2026
3039a2d
对于agent的currentAgentPermission状态进行统一处理,暴露isReadOnly
xuyaqist May 25, 2026
8168e23
修复智能体生成页面,所有字段既由form item的name控制,又由streamValues控制
xuyaqist May 25, 2026
d56c185
更新i18n
xuyaqist May 25, 2026
974852d
Merge branch 'develop' into xyq/refactor_agent_page
xuyaqist May 25, 2026
2320bd0
更新单元测试
xuyaqist May 25, 2026
19c9c00
更新api/agent/search_info返回的结果,新增skills,统一tools和skills
xuyaqist May 25, 2026
f6ed5af
修复单元测试
xuyaqist May 25, 2026
06478e9
Merge branch 'develop' into xyq/refactor_agent_page
xuyaqist May 26, 2026
49c905f
解决冲突
xuyaqist May 26, 2026
06da76b
修复web编译失败问题
xuyaqist May 26, 2026
e29f0a7
处理在创建模式下智能体生成后无法保存的问题
xuyaqist May 26, 2026
d2a6527
删除注释
xuyaqist May 26, 2026
4c01f36
优化代码
xuyaqist May 26, 2026
e826889
Merge branch 'develop' into xyq/refactor_agent_page
xuyaqist May 26, 2026
2ad8beb
修复前端编译失败
xuyaqist May 26, 2026
8693fb2
更新单元测试
xuyaqist May 26, 2026
d5b7879
更新单元测试
xuyaqist May 26, 2026
35f0821
Revert "更新单元测试"
xuyaqist May 26, 2026
9b5c5ee
Reapply "更新单元测试"
xuyaqist May 26, 2026
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: 3 additions & 2 deletions backend/apps/agent_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ async def search_agent_info_api(
"""
Search agent info by agent_id and version_no
version_no defaults to 0 (current/draft version)
Returns permission field indicating whether the user can edit this agent.
"""
try:
_, auth_tenant_id = get_current_user_id(authorization)
user_id, auth_tenant_id = get_current_user_id(authorization)
# Use explicit tenant_id if provided, otherwise fall back to auth tenant_id
effective_tenant_id = tenant_id or auth_tenant_id
return await get_agent_info_impl(agent_id, effective_tenant_id, version_no)
return await get_agent_info_impl(agent_id, effective_tenant_id, version_no, user_id)
except Exception as e:
logger.error(f"Agent search info error: {str(e)}")
raise HTTPException(
Expand Down
45 changes: 43 additions & 2 deletions backend/services/agent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@
search_tools_for_sub_agent
)
from database import skill_db
from services.skill_service import SkillService
from database.agent_version_db import query_version_list
from database.group_db import query_group_ids_by_user
from database.user_tenant_db import get_user_tenant_by_user_id
from database.a2a_agent_db import get_server_agent_ids
from database.a2a_agent_db import get_server_agent_ids, query_external_sub_agents
from services.prompt_template_service import (
SYSTEM_PROMPT_TEMPLATE_ID,
SYSTEM_PROMPT_TEMPLATE_NAME,
Expand Down Expand Up @@ -753,13 +754,31 @@
return create_agent(agent_info={"enabled": False}, tenant_id=tenant_id, user_id=user_id)["agent_id"]


async def get_agent_info_impl(agent_id: int, tenant_id: str, version_no: int = 0):
async def get_agent_info_impl(agent_id: int, tenant_id: str, version_no: int = 0, user_id: Optional[str] = None):

Check warning on line 757 in backend/services/agent_service.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use asynchronous features in this function or remove the `async` keyword.

See more on https://sonarcloud.io/project/issues?id=ModelEngine-Group_nexent&issues=AZ5dy6SscVnEFZITrgYU&open=AZ5dy6SscVnEFZITrgYU&pullRequest=3020

Check failure on line 757 in backend/services/agent_service.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 28 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=ModelEngine-Group_nexent&issues=AZ5dy6SscVnEFZITrgYV&open=AZ5dy6SscVnEFZITrgYV&pullRequest=3020
try:
agent_info = search_agent_info_by_agent_id(agent_id, tenant_id, version_no)
except Exception as e:
logger.error(f"Failed to get agent info: {str(e)}")
raise ValueError(f"Failed to get agent info: {str(e)}")

# Calculate permission if user_id is provided
if user_id is not None:
try:
user_tenant_record = get_user_tenant_by_user_id(user_id) or {}
user_role = str(user_tenant_record.get("user_role") or "").upper()
can_edit_all = user_role in CAN_EDIT_ALL_USER_ROLES

# Permission logic (same as agent list):
# - If creator or can_edit_all: PERMISSION_EDIT
# - Otherwise: use ingroup_permission, default to PERMISSION_READ if None
if can_edit_all or str(agent_info.get("created_by")) == str(user_id):
agent_info["permission"] = PERMISSION_EDIT
else:
ingroup_permission = agent_info.get("ingroup_permission")
agent_info["permission"] = ingroup_permission if ingroup_permission is not None else PERMISSION_READ
except Exception as e:

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.

[代码规范] except Exception: 过于宽泛,建议捕获更具体的异常类型,避免掩盖潜在错误。

logger.warning(f"Failed to calculate agent permission: {str(e)}")

try:
tool_info = search_tools_for_sub_agent(
agent_id=agent_id, tenant_id=tenant_id)
Expand All @@ -776,6 +795,28 @@
logger.error(f"Failed to get sub agent id list: {str(e)}")
agent_info["sub_agent_id_list"] = []

try:
skill_service = SkillService()
instances = skill_service.list_skill_instances(
agent_id=agent_id,
tenant_id=tenant_id,
version_no=version_no
)
agent_info["skills"] = instances
except Exception as e:

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.

[代码规范] except Exception: 过于宽泛,建议捕获更具体的异常类型,避免掩盖潜在错误。

logger.exception(f"Failed to get agent skills: {str(e)}")
agent_info["skills"] = []

try:
external_agents = query_external_sub_agents(
local_agent_id=agent_id, tenant_id=tenant_id, version_no=version_no)
agent_info["external_sub_agent_id_list"] = [
ea["external_agent_id"] for ea in external_agents
]
except Exception as e:

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.

[代码规范] except Exception: 过于宽泛,建议捕获更具体的异常类型,避免掩盖潜在错误。

logger.error(f"Failed to get external sub agents: {str(e)}")

Check failure on line 817 in backend/services/agent_service.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "logging.exception()" instead.

See more on https://sonarcloud.io/project/issues?id=ModelEngine-Group_nexent&issues=AZ5dy6SscVnEFZITrgYX&open=AZ5dy6SscVnEFZITrgYX&pullRequest=3020
agent_info["external_sub_agent_id_list"] = []

if agent_info["model_id"] is not None:
model_info = get_model_by_model_id(agent_info["model_id"])
agent_info["model_name"] = model_info.get("display_name", None) if model_info is not None else None
Expand Down
2 changes: 2 additions & 0 deletions backend/services/config_sync_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def build_models_config(tenant_id: str) -> dict:
def build_model_config(model_config: dict) -> dict:
if not model_config:
return {
"id": None,
"name": "",
"displayName": "",
"apiConfig": {
Expand All @@ -191,6 +192,7 @@ def build_model_config(model_config: dict) -> dict:
}

config = {
"id": model_config.get("model_id"),
"name": get_model_name_from_config(model_config) if model_config else "",
"displayName": model_config.get("display_name", ""),
"apiConfig": {
Expand Down
6 changes: 3 additions & 3 deletions backend/services/prompt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def run_and_flag(tag, sys_prompt):

# Base sections always generated
prompt_configs = [
("duty", prompt_for_generate["DUTY_SYSTEM_PROMPT"]),
("duty", prompt_for_generate["duty_system_prompt"]),
("agent_var_name",
prompt_for_generate["agent_variable_name_system_prompt"]),
("agent_display_name",
Expand All @@ -523,8 +523,8 @@ def run_and_flag(tag, sys_prompt):
# Constraint and few_shots sections are only generated when tools or sub-agents are selected
if has_selected_resources:
prompt_configs.extend([
("constraint", prompt_for_generate["CONSTRAINT_SYSTEM_PROMPT"]),
("few_shots", prompt_for_generate["FEW_SHOTS_SYSTEM_PROMPT"]),
("constraint", prompt_for_generate["constraint_system_prompt"]),
("few_shots", prompt_for_generate["few_shots_system_prompt"]),
])
else:
logger.info("Skipping constraint and few_shots generation: no tools or sub-agents selected")
Expand Down
6 changes: 1 addition & 5 deletions frontend/app/[locale]/agents/AgentVersionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@ export function VersionCardItem({
if (store.currentAgentId === agentId) {
const agentResult = await searchAgentInfo(agentId);
if (agentResult.success && agentResult.data) {
const permissionFromList = currentAgent?.permission ?? undefined;
store.setCurrentAgent({
...agentResult.data,
permission: permissionFromList,
});
store.setCurrentAgent(agentResult.data);
store.triggerForceRefresh();
}
}
Expand Down
Loading
Loading