feat: Implement wiki_config updates in knowledge base management
Added functionality to enable updates for the `wiki_config` field in the `KnowledgeBaseConfig` struct. This includes: 1. **Type Definition Update**: Added `WikiConfig` field to `KnowledgeBaseConfig` to allow JSON unmarshaling during update requests. 2. **Service Layer Enhancement**: Updated the `UpdateKnowledgeBase` method to persist changes to `wiki_config` when provided in the request. 3. **Frontend TypeScript Adjustments**: Enhanced type definitions in the frontend to support `wiki_config`, improving IDE autocomplete and type checking. This fix addresses the critical issue where `wiki_config` was not being updated due to its absence in the `KnowledgeBaseConfig` struct, ensuring proper handling of wiki configurations during knowledge base updates.
This commit is contained in:
@@ -271,6 +271,8 @@ func (e *AgentEngine) executeLoop(
|
||||
"max_iterations": e.config.MaxIterations,
|
||||
})
|
||||
emptyRetries := 0
|
||||
consecutiveSameContent := 0
|
||||
lastResponseContent := ""
|
||||
for state.CurrentRound < e.config.MaxIterations {
|
||||
// Check for context cancellation (request timeout, user cancel, etc.)
|
||||
select {
|
||||
@@ -326,6 +328,27 @@ func (e *AgentEngine) executeLoop(
|
||||
response.Usage.CompletionTokens, response.Usage.TotalTokens)
|
||||
}
|
||||
|
||||
// Detect stuck loops: if the LLM keeps returning the same content
|
||||
// without tool calls (e.g., an unhandled finish reason), break early.
|
||||
if len(response.ToolCalls) == 0 && response.Content != "" {
|
||||
if response.Content == lastResponseContent {
|
||||
consecutiveSameContent++
|
||||
} else {
|
||||
consecutiveSameContent = 0
|
||||
}
|
||||
lastResponseContent = response.Content
|
||||
if consecutiveSameContent >= maxRepeatedResponseRounds {
|
||||
logger.Warnf(ctx, "[Agent][Round-%d] Detected stuck loop: same content repeated %d times (finish=%s), stopping",
|
||||
state.CurrentRound+1, consecutiveSameContent+1, response.FinishReason)
|
||||
state.FinalAnswer = response.Content
|
||||
state.IsComplete = true
|
||||
break
|
||||
}
|
||||
} else {
|
||||
consecutiveSameContent = 0
|
||||
lastResponseContent = ""
|
||||
}
|
||||
|
||||
// Create agent step
|
||||
step := types.AgentStep{
|
||||
Iteration: state.CurrentRound,
|
||||
|
||||
Reference in New Issue
Block a user