返回 DeepSeek-Reasonix
delegation.go
根目录 / cmd / e2ebench / delegation.go
1 package main
2
3 import "fmt"
4
5 // renderDelegation prices what delegation actually bought. Every figure is
6 // host-recorded, so the section answers the only question that matters when an
7 // arm costs more: did the extra agents produce verified work, or just tokens.
8 func renderDelegation(results []result) string {
9 var runs, nested, childCalls, parentCalls, mutations, dupes int
10 var reports, prose, falseDone, downgrades, violations int
11 var scopeHints, namedFiles, evidencePaths, discoveredPaths int
12 solved, total, childTokens := 0, 0, 0
13 for _, r := range results {
14 if r.Skipped {
15 continue
16 }
17 total++
18 if r.Passed {
19 solved++
20 }
21 runs += r.SubagentRuns
22 nested += r.SubagentNestedRuns
23 childCalls += r.SubagentToolCalls
24 parentCalls += r.ToolCalls - r.SubagentToolCalls
25 mutations += r.SubagentMutations
26 dupes += r.DuplicateWorkPaths
27 reports += r.CompletionReports
28 prose += r.CompletionsProsedOnly
29 falseDone += r.FalseCompletions
30 downgrades += r.CriterionDowngrades
31 violations += r.WriteScopeViolations
32 scopeHints += r.ParentScopeHints
33 namedFiles += r.ParentNamedFiles
34 evidencePaths += r.ChildEvidencePaths
35 discoveredPaths += r.ChildDiscoveredPaths
36 if u, ok := r.UsageBySource["subagent"]; ok {
37 childTokens += u.PromptTokens + u.CompletionTokens
38 }
39 }
40 if runs == 0 {
41 // A single-agent arm is a legitimate result, not a missing section: say
42 // so, because an empty section reads as "not measured".
43 if total == 0 {
44 return ""
45 }
46 return fmt.Sprintf("**Delegation**: none — %d/%d solved by a single agent\n\n", solved, total)
47 }
48
49 b := fmt.Sprintf("**Delegation**: **%d** child runs (%d nested) · solved %d/%d (%s)\n",
50 runs, nested, solved, total, pct(solved, total))
51 b += fmt.Sprintf("- work split: parent **%d** tool calls · children **%d** (%s) · child mutations **%d**\n",
52 parentCalls, childCalls, pct(childCalls, parentCalls+childCalls), mutations)
53 // Cumulative prompt tokens over a child's own model calls, so the same
54 // context counts once per call. Labelled as such: it is not fresh material.
55 if childTokens > 0 {
56 b += fmt.Sprintf("- child context re-sent: %s tokens per child, cumulative over its calls (%s across %d runs)\n",
57 comma(childTokens/runs), comma(childTokens), runs)
58 }
59 // Scope and named files are reported apart and as counts. Narrowing the
60 // search is what delegating costs; naming the file is handing over the
61 // answer, and one number would report the cheap one as the expensive one.
62 if evidencePaths > 0 {
63 b += fmt.Sprintf("- evidence origin: children found **%s** of what they looked at themselves (%d/%d paths)\n",
64 pct(discoveredPaths, evidencePaths), discoveredPaths, evidencePaths)
65 b += fmt.Sprintf("- parent delegation text: **%d** scope hint(s) · **%d** file(s) named outright\n",
66 scopeHints, namedFiles)
67 } else {
68 b += "- evidence origin: not scored — no child receipt carried a path\n"
69 }
70 if dupes > 0 {
71 b += fmt.Sprintf("- **duplicate work**: %d file(s) mutated by more than one child\n", dupes)
72 }
73 closed := reports + prose
74 b += fmt.Sprintf("- closed with a checkable claim: **%d/%d** (%s)\n", reports, closed, pct(reports, closed))
75 if falseDone > 0 {
76 b += fmt.Sprintf("- **false completions**: %d run(s), %d criterion claim(s) the host refused\n", falseDone, downgrades)
77 }
78 if violations > 0 {
79 b += fmt.Sprintf("- **write-scope violations**: %d\n", violations)
80 }
81 return b + "\n"
82 }
83
83 lines GO