mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-09-30 13:09:40 +02:00
Add files via upload
This commit is contained in:
1 file changed
+9
-2
@@ -297,6 +297,7 @@ func RunDeepAgent(
|
|||||||
return agent == "" || agent == orchestratorName
|
return agent == "" || agent == orchestratorName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 仅保留主代理最后一次 assistant 输出,避免把多轮中间回复拼接到最终答案。
|
||||||
var lastAssistant string
|
var lastAssistant string
|
||||||
var reasoningStreamSeq int64
|
var reasoningStreamSeq int64
|
||||||
var einoSubReplyStreamSeq int64
|
var einoSubReplyStreamSeq int64
|
||||||
@@ -335,6 +336,7 @@ func RunDeepAgent(
|
|||||||
var toolStreamFragments []schema.ToolCall
|
var toolStreamFragments []schema.ToolCall
|
||||||
var subAssistantBuf strings.Builder
|
var subAssistantBuf strings.Builder
|
||||||
var subReplyStreamID string
|
var subReplyStreamID string
|
||||||
|
var mainAssistantBuf strings.Builder
|
||||||
for {
|
for {
|
||||||
chunk, rerr := mv.MessageStream.Recv()
|
chunk, rerr := mv.MessageStream.Recv()
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
@@ -376,7 +378,7 @@ func RunDeepAgent(
|
|||||||
"conversationId": conversationID,
|
"conversationId": conversationID,
|
||||||
"mcpExecutionIds": snapshotMCPIDs(),
|
"mcpExecutionIds": snapshotMCPIDs(),
|
||||||
})
|
})
|
||||||
lastAssistant += chunk.Content
|
mainAssistantBuf.WriteString(chunk.Content)
|
||||||
} else if !streamsMainAssistant(ev.AgentName) {
|
} else if !streamsMainAssistant(ev.AgentName) {
|
||||||
if progress != nil {
|
if progress != nil {
|
||||||
if subReplyStreamID == "" {
|
if subReplyStreamID == "" {
|
||||||
@@ -401,6 +403,11 @@ func RunDeepAgent(
|
|||||||
toolStreamFragments = append(toolStreamFragments, chunk.ToolCalls...)
|
toolStreamFragments = append(toolStreamFragments, chunk.ToolCalls...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if streamsMainAssistant(ev.AgentName) {
|
||||||
|
if s := strings.TrimSpace(mainAssistantBuf.String()); s != "" {
|
||||||
|
lastAssistant = s
|
||||||
|
}
|
||||||
|
}
|
||||||
if subAssistantBuf.Len() > 0 && progress != nil {
|
if subAssistantBuf.Len() > 0 && progress != nil {
|
||||||
if s := strings.TrimSpace(subAssistantBuf.String()); s != "" {
|
if s := strings.TrimSpace(subAssistantBuf.String()); s != "" {
|
||||||
if subReplyStreamID != "" {
|
if subReplyStreamID != "" {
|
||||||
@@ -455,7 +462,7 @@ func RunDeepAgent(
|
|||||||
"mcpExecutionIds": snapshotMCPIDs(),
|
"mcpExecutionIds": snapshotMCPIDs(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
lastAssistant += body
|
lastAssistant = body
|
||||||
} else if progress != nil {
|
} else if progress != nil {
|
||||||
progress("eino_agent_reply", body, map[string]interface{}{
|
progress("eino_agent_reply", body, map[string]interface{}{
|
||||||
"conversationId": conversationID,
|
"conversationId": conversationID,
|
||||||
|
|||||||
Reference in new issue
Block a user