返回 DeepSeek-Reasonix
subagent_format.go
根目录 / internal / agent / subagent_format.go
1 package agent
2
3 import "strings"
4
5 func FormatSubagentRunResult(answer string, run *SubagentRun, failed bool) string {
6 answer = GuardSubagentHostDecisionText(answer)
7 if run == nil || run.Ref == "" {
8 return answer
9 }
10 if failed {
11 out := FormatSubagentOutcome(SubagentOutcome{Ref: run.Ref, Status: SubagentOutcomeFailed, FinalAnswer: answer})
12 return strings.Replace(out, "Subagent reference: "+run.Ref, "Subagent reference (failed): "+run.Ref, 1)
13 }
14 guidance := FormatSubagentReference(run)
15 if _, rest, ok := strings.Cut(guidance, "\n"); ok {
16 guidance = rest
17 } else {
18 guidance = ""
19 }
20 out := FormatSubagentOutcome(SubagentOutcome{Ref: run.Ref, Status: SubagentOutcomeCompleted})
21 if guidance != "" {
22 out += "\n\n" + guidance
23 }
24 if answer != "" {
25 out += "\n\nFinal answer:\n" + answer
26 }
27 return out
28 }
29
29 lines GO