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 String modelName;
|
||||||
final ModelProviderType providerType;
|
final ModelProviderType providerType;
|
||||||
final String? modelEndpoint;
|
final String? modelEndpoint;
|
||||||
final double temperature;
|
final double? temperature;
|
||||||
final int maxTokens;
|
final int? maxTokens;
|
||||||
final String systemPrompt;
|
final String? systemPrompt;
|
||||||
final bool enableMemory;
|
final bool? enableMemory;
|
||||||
final int conversationWindowSize;
|
final int? conversationWindowSize;
|
||||||
final AgentStatus status;
|
final AgentStatus status;
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
final DateTime updatedAt;
|
final DateTime updatedAt;
|
||||||
@ -261,11 +261,11 @@ class AgentDto {
|
|||||||
required this.modelName,
|
required this.modelName,
|
||||||
required this.providerType,
|
required this.providerType,
|
||||||
this.modelEndpoint,
|
this.modelEndpoint,
|
||||||
required this.temperature,
|
this.temperature,
|
||||||
required this.maxTokens,
|
this.maxTokens,
|
||||||
required this.systemPrompt,
|
this.systemPrompt,
|
||||||
required this.enableMemory,
|
this.enableMemory,
|
||||||
required this.conversationWindowSize,
|
this.conversationWindowSize,
|
||||||
required this.status,
|
required this.status,
|
||||||
required this.createdAt,
|
required this.createdAt,
|
||||||
required this.updatedAt,
|
required this.updatedAt,
|
||||||
@ -300,11 +300,11 @@ class AgentDto {
|
|||||||
modelName: json['modelName'] as String,
|
modelName: json['modelName'] as String,
|
||||||
providerType: parseProviderType(json['providerType']),
|
providerType: parseProviderType(json['providerType']),
|
||||||
modelEndpoint: json['modelEndpoint'] as String?,
|
modelEndpoint: json['modelEndpoint'] as String?,
|
||||||
temperature: (json['temperature'] as num).toDouble(),
|
temperature: json['temperature'] != null ? (json['temperature'] as num).toDouble() : null,
|
||||||
maxTokens: json['maxTokens'] as int,
|
maxTokens: json['maxTokens'] as int?,
|
||||||
systemPrompt: json['systemPrompt'] as String,
|
systemPrompt: json['systemPrompt'] as String?,
|
||||||
enableMemory: json['enableMemory'] as bool,
|
enableMemory: json['enableMemory'] as bool?,
|
||||||
conversationWindowSize: json['conversationWindowSize'] as int,
|
conversationWindowSize: json['conversationWindowSize'] as int?,
|
||||||
status: parseAgentStatus(json['status']),
|
status: parseAgentStatus(json['status']),
|
||||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user