Skip to content

✨Feat: Agent supports model selection.#3313

Merged
WMC001 merged 7 commits into
developfrom
pyh/feat_model_selection_develop
Jun 27, 2026
Merged

✨Feat: Agent supports model selection.#3313
WMC001 merged 7 commits into
developfrom
pyh/feat_model_selection_develop

Conversation

@YehongPan

Copy link
Copy Markdown
Contributor

✨Feat: Agent supports model selection.
[Specification Details]

  1. Agents support selecting multiple models, allowing for switching between them during debugging and chating.
  2. The northbound interface now supports passing in model_id, incremental SQL addition is implemented, and test files have been added.
    [Test Result]
image image image image image 北向查询: image 北向调用: image image

[Specification Details]
1. The northbound interface now supports passing in `model_id`, incremental SQL addition is implemented, and test files have been added.
# Conflicts:
#	frontend/app/[locale]/agents/components/agentInfo/DebugConfig.tsx
[Specification Details]
1. Conflict resolve.
[Specification Details]
1. Frontend Build Fixes.
[Specification Details]
1. Update sql.
# Conflicts:
#	frontend/app/[locale]/chat/internal/chatInterface.tsx
#	frontend/app/[locale]/chat/streaming/chatStreamMain.tsx
#	frontend/types/chat.ts
@WMC001 WMC001 merged commit a038699 into develop Jun 27, 2026
14 of 15 checks passed
@@ -282,55 +282,105 @@ def _get_user_group_ids(user_id: str, tenant_id: str) -> str:
return ""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IndexError Risk

business_logic_model_id[0] extracted from _resolve_model_ids_with_fallback result. If returns empty list [], causes IndexError. Check len > 0 before accessing index 0.

@@ -1,6 +1,6 @@
"use client";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Frontend State Bug

useEffect initializing selectedModelId includes selectedModelId in dependency array. While null check prevents infinite loops, pattern is fragile. Dependency should only include debugModelIds.length and defaultModelId.

@@ -1,6 +1,6 @@
"use client";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Array Index Error

modelIds.indexOf(selectedModelId!) can return -1, causing modelNames[-1] to access last element incorrectly. Add guard: idx >= 0 check before indexing.

@@ -155,23 +155,45 @@ export default function AgentGenerateDetail({}) {
}, [filteredGroups]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Duplicate Model IDs

Backward compatibility logic pushes to mainAgentModelIds without checking if matched model ID already exists. Creates duplicates. Check includes() before pushing.

@@ -282,55 +282,105 @@ def _get_user_group_ids(user_id: str, tenant_id: str) -> str:
return ""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Missing Null Check

_resolve_model_ids_with_fallback returns only valid IDs without falling back to model_display_names when some IDs are missing. Could leave agents with fewer models than intended.

@@ -1,6 +1,6 @@
"use client";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Import Consistency

AgentImportWizard sets agentInfo.model_ids = [selectedModelId] without also setting model_names. Creates inconsistency during import that causes cross-tenant resolution issues.

@@ -921,16 +921,16 @@ export default function AgentImportWizard({
if (modelSelectionMode === "unified") {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Inefficient DB Calls

get_agent_info_impl calls get_model_by_model_id twice for same model_id (once for model_names list, once for legacy model_name). Doubles database calls unnecessarily. Cache first lookup.

@@ -282,55 +282,105 @@ def _get_user_group_ids(user_id: str, tenant_id: str) -> str:
return ""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Missing Validation

model_ids column is ARRAY(Integer) with doc 'max 5 models' but no database-level constraint enforces this. Frontend validates but backend should also validate to prevent data corruption.

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.

3 participants