refactor(agent): remove final_answer tool references and update related logic
- Eliminated all instances of the final_answer tool from the agent's configuration and logic, transitioning to a model where the agent concludes responses with plain text instead. - Updated event handling and response analysis to reflect this change, ensuring that the agent's output is now directly delivered as text without relying on a dedicated final answer tool. - Adjusted localization strings across multiple languages to remove references to final_answer, enhancing clarity and consistency in user-facing messages. - Improved the overall structure of the agent's response handling to streamline the process and reduce potential confusion regarding tool usage. refactor(agent): streamline answer handling and preamble logic - Updated the agent's response handling to treat any text streamed before a tool call as a preamble, ensuring it is not included in the final answer. - Removed the superseded marker logic from the event emission process, simplifying the flow of answer content and enhancing clarity in the UI. - Adjusted the event handling to ensure that preamble segments are correctly retracted and relocated into the steps tree, improving the overall user experience. - Enhanced the agent's internal logic to better manage answer segments and their states during streaming, leading to a more coherent response structure.
This commit is contained in:
+6
-13
@@ -227,14 +227,6 @@ func (e *AgentEngine) streamThinkingToEventBus(
|
||||
}
|
||||
}
|
||||
|
||||
// Handle final_answer tool's streaming answer content
|
||||
if chunk.ResponseType == types.ResponseTypeAnswer {
|
||||
if source, _ := chunk.Data["source"].(string); source == "final_answer_tool" {
|
||||
emitAnswer(chunk.Content)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Handle thinking tool's streaming thought content
|
||||
if chunk.ResponseType == types.ResponseTypeThinking && chunk.Data != nil {
|
||||
if source, _ := chunk.Data["source"].(string); source == "thinking_tool" {
|
||||
@@ -272,11 +264,12 @@ func (e *AgentEngine) streamThinkingToEventBus(
|
||||
return
|
||||
}
|
||||
|
||||
// Plain content channel. This is the model's user-facing answer when
|
||||
// it stops naturally (without the final_answer tool). Split out any
|
||||
// inline <think> reasoning so the thought goes to the thought area
|
||||
// and the genuine answer streams live into the final-answer area —
|
||||
// fixing the "answer first shows under Thinking, then jumps" UX.
|
||||
// Plain content channel. Streamed live to the answer area
|
||||
// (optimistically rendered as the final answer). If the round turns
|
||||
// out to call tools, this was a preamble; the subsequent tool-call
|
||||
// events let the UI retract it from the answer area and relocate it
|
||||
// into the steps. Split out any inline <think> reasoning so it goes
|
||||
// to the thought area instead.
|
||||
if chunk.Content != "" {
|
||||
thinkPart, answerPart := splitter.Feed(chunk.Content)
|
||||
if thinkPart != "" {
|
||||
|
||||
Reference in New Issue
Block a user