返回 DeepSeek-Reasonix
run_turn_evidence.go
根目录 / internal / agent / run_turn_evidence.go
1 package agent
2
3 import (
4 "context"
5
6 "reasonix/internal/jobs"
7 )
8
9 // leasePendingBackgroundEvidence re-leases this session's uncommitted job
10 // mutations after the new turn resets a failed or cancelled turn's ledger.
11 // Process restarts also begin with an empty ledger while the job manager still
12 // owns the uncommitted evidence. Plan turns defer the lease until approval.
13 func (a *Agent) leasePendingBackgroundEvidence(ctx context.Context) {
14 if a.task.ledger == nil || a.svc.jobs == nil || a.planMode.Load() {
15 return
16 }
17 session := jobs.SessionFromContext(ctx)
18 for _, jobID := range a.svc.jobs.PendingEvidenceJobIDsForSession(session) {
19 summary, ready := a.svc.jobs.TryLeaseEvidenceForSession(session, jobID)
20 if !ready || !a.task.ledger.NoteBackgroundLease(session, jobID) {
21 continue
22 }
23 a.task.ledger.MergeChild(summary)
24 }
25 }
26
26 lines GO