返回 DeepSeek-Reasonix
planner_route.go
根目录 / internal / agent / planner_route.go
1 package agent
2
3 import (
4 "context"
5 "strings"
6 )
7
8 // PlannerRoute describes how a two-model turn should flow. It is deliberately
9 // separate from explicit Plan Mode: ExecutorOnly lets the ordinary executor
10 // handle that host-owned workflow without invoking a second planner.
11 type PlannerRoute string
12
13 const (
14 PlannerRouteExecutorOnly PlannerRoute = "executor_only"
15 PlannerRoutePlanAndExecute PlannerRoute = "plan_and_execute"
16 PlannerRoutePlanForApproval PlannerRoute = "plan_for_approval"
17 PlannerRoutePlanOnly PlannerRoute = "plan_only"
18 )
19
20 // PlannerIntent is the explicit planner request for one turn. Ordinary work is
21 // always executor-only; the planner never infers complexity from wording.
22 type PlannerIntent = PlannerRoute
23
24 // PlannerDecision is the deterministic, host-owned routing result for one turn.
25 // Reason is an opaque privacy-safe code for diagnostics; user text never belongs
26 // in it.
27 type PlannerDecision struct {
28 Route PlannerRoute
29 Reason string
30 }
31
32 // PlannerPolicy makes one deterministic routing decision from trusted turn
33 // context plus the composed model input.
34 type PlannerPolicy func(context.Context, string) PlannerDecision
35
36 func normalizePlannerDecision(d PlannerDecision) PlannerDecision {
37 switch d.Route {
38 case PlannerRouteExecutorOnly, PlannerRoutePlanAndExecute, PlannerRoutePlanForApproval, PlannerRoutePlanOnly:
39 default:
40 d.Route = PlannerRouteExecutorOnly
41 }
42 d.Reason = strings.TrimSpace(d.Reason)
43 if d.Reason == "" {
44 d.Reason = "default"
45 }
46 return d
47 }
48
48 lines GO