返回 DeepSeek-Reasonix
taskstate.go
根目录 / internal / agent / taskstate.go
1 package agent
2
3 import "reasonix/internal/evidence"
4
5 // taskRuntime is the host state shared by every Agent.Run continuing one
6 // delivery scope: one ledger, one bill, one set of failure budgets. Its
7 // lifetime sits between the session and the turn — SetSession replaces it
8 // wholesale, beginRunTurn restarts it when the scope changes, and state valid
9 // for exactly one Run lives in perTurnState instead.
10 type taskRuntime struct {
11 scopeID string
12 checkpoint evidence.DeliveryCheckpoint
13 ledger *evidence.Ledger
14 outcome *evidence.OutcomeTracker
15 budget runBudget
16 ebm ebmState
17 }
18
19 // restartLedger begins a new task's accounting. It is written as one assignment
20 // so a field added to taskRuntime resets by default; the four fields carried
21 // forward are named because each answers to its own condition in beginRunTurn.
22 func (t *taskRuntime) restartLedger() {
23 *t = taskRuntime{
24 scopeID: t.scopeID,
25 checkpoint: t.checkpoint,
26 ledger: t.ledger,
27 outcome: evidence.NewOutcomeTracker(),
28 budget: runBudget{limit: t.budget.limit},
29 }
30 t.ledger.Reset()
31 }
32
33 func (t *taskRuntime) prepareScope(scoped bool, scopeID string) {
34 }
35
35 lines GO