返回 DeepSeek-Reasonix
task_budget.go
根目录 / internal / agent / task_budget.go
1 package agent
2
3 import "context"
4
5 // childMaxSteps resolves a sub-agent budget; an explicit request always wins.
6 func (t *TaskTool) childMaxSteps(requested int) int {
7 return childMaxStepsForParent(t.maxSteps, requested)
8 }
9
10 func childMaxStepsForParent(parent, requested int) int {
11 if requested > 0 {
12 return requested
13 }
14 if parent <= 0 {
15 return 0
16 }
17 return max(parent/2, 5)
18 }
19
20 func (t *TaskTool) childMaxStepsForContext(_ context.Context, requested int) int {
21 return t.childMaxSteps(requested)
22 }
23
24 func (t *TaskTool) childMaxStepsForSpec(ctx context.Context, spec *ProfileExecSpec) (context.Context, int) {
25 applyReviewBudget(spec)
26 fillChildFacts(ctx, spec)
27 if spec == nil {
28 return ctx, t.childMaxStepsForContext(ctx, 0)
29 }
30 ctx = withChildOutputBudget(ctx, spec.Sched.MaxOutputTokens)
31 return ctx, t.childMaxStepsForContext(ctx, spec.Sched.MaxSteps)
32 }
33
33 lines GO