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 <noreply@anthropic.com>
This commit is contained in:
parent
a7cbcc331b
commit
797ee55caf
@ -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),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user