]> git.giacomolli.uk - onechat/blobdiff - turn.go
Use both logs for WhatsApp import cutoffs
[onechat] / turn.go
diff --git a/turn.go b/turn.go
index e559950675925ccf3fb51d470c7ce8a2af2bb803..e0bd489f323549a19f19706d4e68fd04c656c762 100644 (file)
--- a/turn.go
+++ b/turn.go
@@ -59,6 +59,7 @@ func newTurnLoop(agent *Agent, memory *Memory, subagents *Subagents, whatsapp *W
                whatsapp:  whatsapp,
                schedules: schedules,
                workdir:   agent.config.Workdir,
+               agentName: agent.config.Name,
        }
 
        return l, nil
@@ -92,18 +93,19 @@ type Event struct {
 // active belongs to the running turn. The mutex protects pending, cancel, and
 // failure.
 type TurnLoop struct {
-       agent    *Agent
-       memory   *Memory
-       client   ChainClient
-       tools    *Toolbox
-       runs     *SubagentRuns
-       layout   *ViewLayout
-       clock    func() time.Time
-       logger   *slog.Logger
-       notify   func(Event)
-       wake     chan struct{}
-       messages *DaemonMessages
-       active   []Message
+       agent     *Agent
+       memory    *Memory
+       client    ChainClient
+       tools     *Toolbox
+       runs      *SubagentRuns
+       layout    *ViewLayout
+       clock     func() time.Time
+       logger    *slog.Logger
+       notify    func(Event)
+       wake      chan struct{}
+       messages  *DaemonMessages
+       openChild func(context.Context, *Agent) (*DaemonAgent, error)
+       active    []Message
 
        mutex   sync.Mutex
        pending []Message
@@ -447,9 +449,14 @@ func (l *TurnLoop) take() []Message {
 }
 
 // state returns the per-turn state: the end of the view, and the date and time
-// of the turn.
+// of the turn, then the names and responsibilities of its children.
 func (l *TurnLoop) state() string {
-       return "</chat>\n\nNow: " + l.clock().Format("Monday 2006-01-02 15:04 -07:00")
+       state := "</chat>\n\nNow: " + l.clock().Format("Monday 2006-01-02 15:04 -07:00")
+       if l.messages != nil {
+               state += l.messages.ChildState(l.agent.config.Name)
+       }
+
+       return state
 }
 
 // turnError returns the text of the error that ended a turn.