mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-02 05:57:29 +08:00
refactor: default-enable session planning and scheduling without config flags
This commit is contained in:
@@ -54,8 +54,6 @@ type AgentLoop struct {
|
||||
runtimeCompactionNote string
|
||||
startupCompactionNote string
|
||||
systemRewriteTemplate string
|
||||
sessionAutoPlan bool
|
||||
sessionAutoPlanMax int
|
||||
audit *triggerAudit
|
||||
running bool
|
||||
intentMu sync.RWMutex
|
||||
@@ -242,25 +240,16 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers
|
||||
runtimeCompactionNote: cfg.Agents.Defaults.Texts.RuntimeCompactionNote,
|
||||
startupCompactionNote: cfg.Agents.Defaults.Texts.StartupCompactionNote,
|
||||
systemRewriteTemplate: cfg.Agents.Defaults.Texts.SystemRewriteTemplate,
|
||||
sessionAutoPlan: cfg.Agents.Defaults.RuntimeControl.SessionAutoPlanEnabled,
|
||||
sessionAutoPlanMax: cfg.Agents.Defaults.RuntimeControl.SessionAutoPlanMaxTasks,
|
||||
audit: newTriggerAudit(workspace),
|
||||
running: false,
|
||||
intentHints: map[string]string{},
|
||||
sessionScheduler: NewSessionScheduler(cfg.Agents.Defaults.RuntimeControl.SessionMaxParallelRuns),
|
||||
sessionScheduler: NewSessionScheduler(0),
|
||||
ekg: ekg.New(workspace),
|
||||
sessionProvider: map[string]string{},
|
||||
sessionStreamed: map[string]bool{},
|
||||
providerResponses: map[string]config.ProviderResponsesConfig{},
|
||||
telegramStreaming: cfg.Channels.Telegram.Streaming,
|
||||
}
|
||||
if !cfg.Agents.Defaults.RuntimeControl.SessionResourceSchedulingEnabled {
|
||||
loop.sessionScheduler = nil
|
||||
}
|
||||
if loop.sessionAutoPlanMax <= 0 {
|
||||
loop.sessionAutoPlanMax = 4
|
||||
}
|
||||
|
||||
// Initialize provider fallback chain (primary + proxy_fallbacks).
|
||||
loop.providerPool = map[string]providers.LLMProvider{}
|
||||
loop.providerNames = []string{}
|
||||
|
||||
@@ -12,8 +12,6 @@ import (
|
||||
"clawgo/pkg/scheduling"
|
||||
)
|
||||
|
||||
const defaultSessionAutoPlanMaxTasks = 4
|
||||
|
||||
type plannedTask struct {
|
||||
Index int
|
||||
Content string
|
||||
@@ -42,9 +40,6 @@ func (al *AgentLoop) planSessionTasks(msg bus.InboundMessage) []plannedTask {
|
||||
if base == "" {
|
||||
return nil
|
||||
}
|
||||
if !al.sessionAutoPlan {
|
||||
return []plannedTask{{Index: 1, Content: base, ResourceKeys: scheduling.DeriveResourceKeys(base)}}
|
||||
}
|
||||
if msg.Channel == "system" || msg.Channel == "internal" {
|
||||
return []plannedTask{{Index: 1, Content: base, ResourceKeys: scheduling.DeriveResourceKeys(base)}}
|
||||
}
|
||||
@@ -62,14 +57,6 @@ func (al *AgentLoop) planSessionTasks(msg bus.InboundMessage) []plannedTask {
|
||||
return []plannedTask{{Index: 1, Content: base, ResourceKeys: scheduling.DeriveResourceKeys(base)}}
|
||||
}
|
||||
|
||||
maxTasks := al.sessionAutoPlanMax
|
||||
if maxTasks <= 0 {
|
||||
maxTasks = defaultSessionAutoPlanMaxTasks
|
||||
}
|
||||
if len(segments) > maxTasks {
|
||||
segments = segments[:maxTasks]
|
||||
}
|
||||
|
||||
out := make([]plannedTask, 0, len(segments))
|
||||
for i, seg := range segments {
|
||||
content := strings.TrimSpace(seg)
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestSplitPlannedSegments_Bullets(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPlanSessionTasks_Semicolon(t *testing.T) {
|
||||
loop := &AgentLoop{sessionAutoPlan: true, sessionAutoPlanMax: 4}
|
||||
loop := &AgentLoop{}
|
||||
tasks := loop.planSessionTasks(bus.InboundMessage{Channel: "cli", Content: "修复 pkg/a.go;修复 pkg/b.go"})
|
||||
if len(tasks) != 2 {
|
||||
t.Fatalf("expected 2 tasks, got %#v", tasks)
|
||||
@@ -32,8 +32,6 @@ func TestProcessPlannedMessage_AggregatesResults(t *testing.T) {
|
||||
{Content: "done-b", FinishReason: "stop"},
|
||||
}}
|
||||
loop := setupLoop(t, rp)
|
||||
loop.sessionAutoPlan = true
|
||||
loop.sessionAutoPlanMax = 4
|
||||
|
||||
resp, err := loop.processPlannedMessage(context.Background(), bus.InboundMessage{
|
||||
Channel: "cli",
|
||||
|
||||
Reference in New Issue
Block a user