From 797ee55caf60b8a345da38775db93139ae2729ff Mon Sep 17 00:00:00 2001 From: Svrnty Date: Mon, 27 Oct 2025 00:01:21 -0400 Subject: [PATCH] fix: Make AgentDto configuration fields nullable for list endpoint compatibility The backend /api/agents list endpoint returns a lightweight DTO without configuration fields (temperature, maxTokens, systemPrompt, enableMemory, conversationWindowSize). This caused a TypeError when parsing the response as these fields were required in AgentDto. Changes: - Made 5 configuration fields nullable in AgentDto - Updated constructor to accept optional values - Fixed fromJson() to safely handle null values with explicit checks - Maintains backward compatibility with full agent detail responses This fix resolves the "Error Loading Agents" issue and allows the agents page to display correctly. List endpoint now parses successfully while detail endpoints still provide full configuration. Fixes: TypeError: null: type 'Null' is not a subtype of type 'num' Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../lib/api/endpoints/agent_endpoint.dart | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/FRONTEND/lib/api/endpoints/agent_endpoint.dart b/FRONTEND/lib/api/endpoints/agent_endpoint.dart index 024e169..bf62574 100644 --- a/FRONTEND/lib/api/endpoints/agent_endpoint.dart +++ b/FRONTEND/lib/api/endpoints/agent_endpoint.dart @@ -243,11 +243,11 @@ class AgentDto { final String modelName; final ModelProviderType providerType; final String? modelEndpoint; - final double temperature; - final int maxTokens; - final String systemPrompt; - final bool enableMemory; - final int conversationWindowSize; + final double? temperature; + final int? maxTokens; + final String? systemPrompt; + final bool? enableMemory; + final int? conversationWindowSize; final AgentStatus status; final DateTime createdAt; final DateTime updatedAt; @@ -261,11 +261,11 @@ class AgentDto { required this.modelName, required this.providerType, this.modelEndpoint, - required this.temperature, - required this.maxTokens, - required this.systemPrompt, - required this.enableMemory, - required this.conversationWindowSize, + this.temperature, + this.maxTokens, + this.systemPrompt, + this.enableMemory, + this.conversationWindowSize, required this.status, required this.createdAt, required this.updatedAt, @@ -300,11 +300,11 @@ class AgentDto { modelName: json['modelName'] as String, providerType: parseProviderType(json['providerType']), modelEndpoint: json['modelEndpoint'] as String?, - temperature: (json['temperature'] as num).toDouble(), - maxTokens: json['maxTokens'] as int, - systemPrompt: json['systemPrompt'] as String, - enableMemory: json['enableMemory'] as bool, - conversationWindowSize: json['conversationWindowSize'] as int, + temperature: json['temperature'] != null ? (json['temperature'] as num).toDouble() : null, + maxTokens: json['maxTokens'] as int?, + systemPrompt: json['systemPrompt'] as String?, + enableMemory: json['enableMemory'] as bool?, + conversationWindowSize: json['conversationWindowSize'] as int?, status: parseAgentStatus(json['status']), createdAt: DateTime.parse(json['createdAt'] as String), updatedAt: DateTime.parse(json['updatedAt'] as String),