✨Feat: Agent supports model selection.#3313
Conversation
[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
| @@ -282,55 +282,105 @@ def _get_user_group_ids(user_id: str, tenant_id: str) -> str: | |||
| return "" | |||
There was a problem hiding this comment.
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"; | |||
There was a problem hiding this comment.
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"; | |||
There was a problem hiding this comment.
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]); | |||
There was a problem hiding this comment.
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 "" | |||
There was a problem hiding this comment.
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"; | |||
There was a problem hiding this comment.
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") { | |||
There was a problem hiding this comment.
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 "" | |||
There was a problem hiding this comment.
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.
✨Feat: Agent supports model selection.
[Specification Details]
model_id, incremental SQL addition is implemented, and test files have been added.[Test Result]