feat: implement final_answer tool and enhance agent duration tracking
- Introduced the final_answer tool to ensure agents submit their complete responses as the last action, improving response accuracy and consistency. - Updated the agent engine to log detailed information about tool calls and responses, including the total duration of agent execution. - Enhanced the chat message model to include agent_duration_ms, tracking the total execution time from query start to answer delivery. - Implemented JSON field extraction for streaming responses, allowing for more efficient handling of tool call outputs. These changes significantly improve the agent's response handling and ensure that final answers are consistently delivered, enhancing overall user experience.
This commit is contained in:
@@ -347,8 +347,9 @@ func (s *agentService) registerTools(
|
||||
allowedTools = append(allowedTools, tools.ToolWebSearch)
|
||||
allowedTools = append(allowedTools, tools.ToolWebFetch)
|
||||
}
|
||||
logger.Infof(ctx, "Registering tools: %v, webSearchEnabled: %v", allowedTools, config.WebSearchEnabled)
|
||||
|
||||
logger.Infof(ctx, "Registering tools: %v, webSearchEnabled: %v", allowedTools, config.WebSearchEnabled)
|
||||
allowedTools = append(allowedTools, tools.ToolFinalAnswer)
|
||||
// Register each allowed tool
|
||||
for _, toolName := range allowedTools {
|
||||
var toolToRegister types.Tool
|
||||
@@ -402,6 +403,9 @@ func (s *agentService) registerTools(
|
||||
toolToRegister = tools.NewDataSchemaTool(s.knowledgeService, s.chunkService.GetRepository())
|
||||
logger.Infof(ctx, "Registered data_schema tool")
|
||||
|
||||
case tools.ToolFinalAnswer:
|
||||
toolToRegister = tools.NewFinalAnswerTool()
|
||||
logger.Infof(ctx, "Registered final_answer tool")
|
||||
default:
|
||||
logger.Warnf(ctx, "Unknown tool: %s", toolName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user