Merge pull request #3169 from Alix-007/fix/evolution-heartbeat-coldpath
fix(evolution): skip cold path for heartbeat turns
This commit is contained in:
commit
dff16dbb91
2 changed files with 32 additions and 0 deletions
|
|
@ -202,6 +202,9 @@ func (b *evolutionBridge) handleTurnEndAsync(meta EventMeta, payload TurnEndPayl
|
||||||
FinalSuccessfulPath: append([]string(nil), payload.FinalSuccessfulPath...),
|
FinalSuccessfulPath: append([]string(nil), payload.FinalSuccessfulPath...),
|
||||||
SkillContextSnapshots: toEvolutionSkillContextSnapshots(payload.SkillContextSnapshots),
|
SkillContextSnapshots: toEvolutionSkillContextSnapshots(payload.SkillContextSnapshots),
|
||||||
}
|
}
|
||||||
|
if isEvolutionHeartbeatInput(input) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
b.rememberScheduledColdPathWorkspace(input.Workspace)
|
b.rememberScheduledColdPathWorkspace(input.Workspace)
|
||||||
|
|
||||||
b.closeMu.Lock()
|
b.closeMu.Lock()
|
||||||
|
|
@ -228,6 +231,10 @@ func (b *evolutionBridge) handleTurnEndAsync(meta EventMeta, payload TurnEndPayl
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isEvolutionHeartbeatInput(input evolution.TurnCaseInput) bool {
|
||||||
|
return strings.EqualFold(strings.TrimSpace(input.SessionKey), "heartbeat")
|
||||||
|
}
|
||||||
|
|
||||||
func (b *evolutionBridge) subscribeRuntimeEvents(ch runtimeevents.EventChannel) error {
|
func (b *evolutionBridge) subscribeRuntimeEvents(ch runtimeevents.EventChannel) error {
|
||||||
if b == nil || ch == nil {
|
if b == nil || ch == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,31 @@ func TestEvolutionBridge_DraftModeAutomaticallyRunsColdPathAndCreatesDraftFile(t
|
||||||
waitForDrafts(t, filepath.Join(tmpDir, "state", "evolution", "skill-drafts.json"), 1)
|
waitForDrafts(t, filepath.Join(tmpDir, "state", "evolution", "skill-drafts.json"), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEvolutionBridge_DraftModeDoesNotRunColdPathForHeartbeat(t *testing.T) {
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
seedReadyRule(t, tmpDir)
|
||||||
|
|
||||||
|
al := newEvolutionTestLoop(t, tmpDir, config.EvolutionConfig{
|
||||||
|
Enabled: true,
|
||||||
|
Mode: "draft",
|
||||||
|
}, &simpleMockProvider{
|
||||||
|
response: `{"target_skill_name":"weather","draft_type":"shortcut","change_kind":"append","human_summary":"unexpected heartbeat draft","body_or_patch":"## Unexpected"}`,
|
||||||
|
})
|
||||||
|
defer al.Close()
|
||||||
|
|
||||||
|
resp, err := al.ProcessHeartbeat(context.Background(), "check heartbeat tasks", "telegram", "chat-1")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ProcessHeartbeat failed: %v", err)
|
||||||
|
}
|
||||||
|
if resp == "" {
|
||||||
|
t.Fatal("expected non-empty heartbeat response")
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(150 * time.Millisecond)
|
||||||
|
assertNotExists(t, filepath.Join(tmpDir, "state", "evolution", "task-records.jsonl"))
|
||||||
|
assertNotExists(t, filepath.Join(tmpDir, "state", "evolution", "skill-drafts.json"))
|
||||||
|
}
|
||||||
|
|
||||||
func TestEvolutionBridge_ScheduledModeDoesNotRunColdPathAfterTurn(t *testing.T) {
|
func TestEvolutionBridge_ScheduledModeDoesNotRunColdPathAfterTurn(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
seedReadyRule(t, tmpDir)
|
seedReadyRule(t, tmpDir)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue