Add autonomous world runtime

This commit is contained in:
lpf
2026-03-16 21:06:46 +08:00
parent 5a6a455f43
commit 7f2ecfab58
13 changed files with 1342 additions and 13 deletions

View File

@@ -443,6 +443,7 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers
loop.model = strings.TrimSpace(primaryModel)
}
go loop.runAgentDigestTicker()
go loop.runWorldTicker()
// Initialize provider fallback chain (primary + inferred providers).
loop.providerChain = []providerCandidate{}
loop.providerPool = map[string]providers.LLMProvider{}
@@ -2840,6 +2841,19 @@ func (al *AgentLoop) runAgentDigestTicker() {
}
}
func (al *AgentLoop) runWorldTicker() {
if al == nil || al.worldRuntime == nil || !al.worldRuntime.Enabled() {
return
}
ticker := time.NewTicker(3 * time.Second)
defer ticker.Stop()
for range ticker.C {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
_, _ = al.worldRuntime.AutoTick(ctx, "world_loop")
cancel()
}
}
func (al *AgentLoop) flushDueAgentDigests(now time.Time) {
if al == nil || al.bus == nil {
return