返回 DeepSeek-Reasonix
delegation_admission.go
根目录 / internal / agent / delegation_admission.go
1 package agent
2
3 import (
4 "reasonix/internal/event"
5 "reasonix/internal/provider"
6 )
7
8 // admissionGatedDelegations are the delegation tools expensive enough to need
9 // an admission reason on local-fix turns. task/fleet/explore joined research
10 // after a paired measurement: forcing delegation on identical work cost 2-4x
11 // the tokens and wall clock with no change in outcome. Shadow-only — a deny is
12 // recorded, never enforced; two tasks do not justify blocking a user's call.
13 var admissionGatedDelegations = map[string]bool{
14 "research": true,
15 "explore": true,
16 "task": true,
17 "fleet": true,
18 }
19
20 // delegationAdmission is the shadow verdict for one gated delegation call:
21 // local mutation-shaped turns get no expensive external research unless the
22 // user asked for it or the call cites an external source. Pure function.
23 func delegationAdmission(input, args string) (verdict, reason, intent string) {
24 _, _ = input, args
25 return "allow", "model_decides", ""
26 }
27
28 // observeDelegationAdmission records a shadow admission verdict for every
29 // gated delegation call in the batch. Observed, never enforced. The turn text
30 // is the bounded classifier source the delivery gates already store, so the
31 // shadow and the gates judge the same words.
32 func (a *Agent) observeDelegationAdmission(calls []provider.ToolCall) {
33 for _, call := range calls {
34 if !admissionGatedDelegations[call.Name] {
35 continue
36 }
37 verdict, reason, intent := delegationAdmission(a.turn.recoveryTaskSummary, call.Arguments)
38 event.RecordDelegationAdmission(a.svc.sink, event.DelegationAdmissionAudit{
39 Tool: call.Name, Verdict: verdict, Reason: reason, Intent: intent,
40 })
41 }
42 }
43
43 lines GO