fix(client): align UpdateAgent request types with internal API

Sync AgentConfig, UpdateAgentRequest, and CreateAgentRequest JSON fields
with internal/types.CustomAgentConfig and handler request structs so SDK
clients can send and receive the full agent configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
qingfhuang
2026-05-19 20:06:21 +08:00
committed by lyingbug
parent bb95488ac8
commit 6a6513caba
+67 -43
View File
@@ -22,63 +22,87 @@ type Agent struct {
IsBuiltin bool `json:"is_builtin"` IsBuiltin bool `json:"is_builtin"`
TenantID uint64 `json:"tenant_id"` TenantID uint64 `json:"tenant_id"`
CreatedBy string `json:"created_by"` CreatedBy string `json:"created_by"`
RunnableByViewer bool `json:"runnable_by_viewer"`
Config *AgentConfig `json:"config"` Config *AgentConfig `json:"config"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`
CreatorName string `json:"creator_name,omitempty"`
} }
// AgentConfig represents the configuration for an agent // AgentConfig represents the configuration for an agent.
// Field names and JSON tags mirror internal/types.CustomAgentConfig.
type AgentConfig struct { type AgentConfig struct {
AgentMode string `json:"agent_mode"` // "quick-answer" or "smart-reasoning" AgentMode string `json:"agent_mode"`
SystemPrompt string `json:"system_prompt,omitempty"` AgentType string `json:"agent_type,omitempty"`
ContextTemplate string `json:"context_template,omitempty"` SystemPrompt string `json:"system_prompt"`
ModelID string `json:"model_id,omitempty"` SystemPromptID string `json:"system_prompt_id,omitempty"`
RerankModelID string `json:"rerank_model_id,omitempty"` ContextTemplate string `json:"context_template"`
Temperature float64 `json:"temperature,omitempty"` ContextTemplateID string `json:"context_template_id,omitempty"`
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"` ModelID string `json:"model_id"`
MaxIterations int `json:"max_iterations,omitempty"` RerankModelID string `json:"rerank_model_id"`
AllowedTools []string `json:"allowed_tools,omitempty"` Temperature float64 `json:"temperature"`
MCPSelectionMode string `json:"mcp_selection_mode,omitempty"` // "all", "selected", "none" MaxCompletionTokens int `json:"max_completion_tokens"`
MCPServices []string `json:"mcp_services,omitempty"` Thinking *bool `json:"thinking"`
KBSelectionMode string `json:"kb_selection_mode,omitempty"` // "all", "selected", "none" MaxIterations int `json:"max_iterations"`
KnowledgeBases []string `json:"knowledge_bases,omitempty"` LLMCallTimeout int `json:"llm_call_timeout,omitempty"`
SupportedFileTypes []string `json:"supported_file_types,omitempty"` AllowedTools []string `json:"allowed_tools"`
FAQPriorityEnabled bool `json:"faq_priority_enabled,omitempty"` MCPSelectionMode string `json:"mcp_selection_mode"`
FAQDirectAnswerThreshold float64 `json:"faq_direct_answer_threshold,omitempty"` MCPServices []string `json:"mcp_services"`
FAQScoreBoost float64 `json:"faq_score_boost,omitempty"` SkillsSelectionMode string `json:"skills_selection_mode"`
WebSearchEnabled bool `json:"web_search_enabled,omitempty"` SelectedSkills []string `json:"selected_skills"`
WebSearchMaxResults int `json:"web_search_max_results,omitempty"` KBSelectionMode string `json:"kb_selection_mode"`
MultiTurnEnabled bool `json:"multi_turn_enabled,omitempty"` KnowledgeBases []string `json:"knowledge_bases"`
HistoryTurns int `json:"history_turns,omitempty"` RetrieveKBOnlyWhenMentioned bool `json:"retrieve_kb_only_when_mentioned"`
EmbeddingTopK int `json:"embedding_top_k,omitempty"` RetainRetrievalHistory bool `json:"retain_retrieval_history"`
KeywordThreshold float64 `json:"keyword_threshold,omitempty"` ImageUploadEnabled bool `json:"image_upload_enabled"`
VectorThreshold float64 `json:"vector_threshold,omitempty"` VLMModelID string `json:"vlm_model_id"`
RerankTopK int `json:"rerank_top_k,omitempty"` AudioUploadEnabled bool `json:"audio_upload_enabled"`
RerankThreshold float64 `json:"rerank_threshold,omitempty"` ASRModelID string `json:"asr_model_id"`
EnableQueryExpansion bool `json:"enable_query_expansion,omitempty"` ImageStorageProvider string `json:"image_storage_provider"`
EnableRewrite bool `json:"enable_rewrite,omitempty"` SupportedFileTypes []string `json:"supported_file_types"`
RewritePromptSystem string `json:"rewrite_prompt_system,omitempty"` DataAnalysisEnabled bool `json:"data_analysis_enabled"`
RewritePromptUser string `json:"rewrite_prompt_user,omitempty"` FAQPriorityEnabled bool `json:"faq_priority_enabled"`
FAQDirectAnswerThreshold float64 `json:"faq_direct_answer_threshold"`
FAQScoreBoost float64 `json:"faq_score_boost"`
WebSearchEnabled bool `json:"web_search_enabled"`
WebSearchMaxResults int `json:"web_search_max_results"`
WebSearchProviderID string `json:"web_search_provider_id,omitempty"`
WebFetchEnabled bool `json:"web_fetch_enabled"`
WebFetchTopN int `json:"web_fetch_top_n,omitempty"`
MultiTurnEnabled bool `json:"multi_turn_enabled"`
HistoryTurns int `json:"history_turns"`
EmbeddingTopK int `json:"embedding_top_k"`
KeywordThreshold float64 `json:"keyword_threshold"`
VectorThreshold float64 `json:"vector_threshold"`
RerankTopK int `json:"rerank_top_k"`
RerankThreshold float64 `json:"rerank_threshold"`
EnableQueryExpansion bool `json:"enable_query_expansion"`
EnableRewrite bool `json:"enable_rewrite"`
RewritePromptSystem string `json:"rewrite_prompt_system"`
RewritePromptUser string `json:"rewrite_prompt_user"`
QueryUnderstandModelID string `json:"query_understand_model_id,omitempty"` QueryUnderstandModelID string `json:"query_understand_model_id,omitempty"`
FallbackStrategy string `json:"fallback_strategy,omitempty"` // "fixed" or "model" FallbackStrategy string `json:"fallback_strategy"`
FallbackResponse string `json:"fallback_response,omitempty"` FallbackResponse string `json:"fallback_response"`
FallbackPrompt string `json:"fallback_prompt,omitempty"` FallbackPrompt string `json:"fallback_prompt"`
SuggestedPrompts []string `json:"suggested_prompts,omitempty"`
} }
// CreateAgentRequest represents the request to create an agent // CreateAgentRequest represents the request to create an agent.
// JSON field names mirror internal/handler.CreateAgentRequest.
type CreateAgentRequest struct { type CreateAgentRequest struct {
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description,omitempty"` Description string `json:"description"`
Avatar string `json:"avatar,omitempty"` Avatar string `json:"avatar"`
Config *AgentConfig `json:"config,omitempty"` Config *AgentConfig `json:"config"`
} }
// UpdateAgentRequest represents the request to update an agent // UpdateAgentRequest represents the request to update an agent.
// JSON field names mirror internal/handler.UpdateAgentRequest.
type UpdateAgentRequest struct { type UpdateAgentRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name"`
Description string `json:"description,omitempty"` Description string `json:"description"`
Avatar string `json:"avatar,omitempty"` Avatar string `json:"avatar"`
Config *AgentConfig `json:"config,omitempty"` Config *AgentConfig `json:"config"`
} }
// AgentResponse represents the API response containing a single agent // AgentResponse represents the API response containing a single agent