]> git.giacomolli.uk - onechat/blobdiff - turn.go
Run each child with its own files and loop
[onechat] / turn.go
diff --git a/turn.go b/turn.go
index 637d783b70dfb8c5eb80eb521e7e0510b1db13fc..2e5e50eef577cd3da3656dbaaa3122569ed112da 100644 (file)
--- a/turn.go
+++ b/turn.go
@@ -13,7 +13,8 @@ import (
 // newTurnLoop returns the loop of agent with its memory, its subagents, and the
 // WhatsApp link and the schedules of its tools. Its calls go through client,
 // and notify gets each event. The clock gives the date of a turn. logger gets
 // newTurnLoop returns the loop of agent with its memory, its subagents, and the
 // WhatsApp link and the schedules of its tools. Its calls go through client,
 // and notify gets each event. The clock gives the date of a turn. logger gets
-// the failed turns and the ends of the subagents.
+// the failed turns and the ends of the subagents. A child has no WhatsApp
+// tools, even when the caller supplies a link.
 func newTurnLoop(agent *Agent, memory *Memory, subagents *Subagents, whatsapp *WhatsApp, schedules *Schedules, client ChainClient, clock func() time.Time, logger *slog.Logger, notify func(Event)) (*TurnLoop, error) {
        layout, err := loadViewLayout(filepath.Join(agent.dir, viewLayoutFileName))
        if err != nil {
 func newTurnLoop(agent *Agent, memory *Memory, subagents *Subagents, whatsapp *WhatsApp, schedules *Schedules, client ChainClient, clock func() time.Time, logger *slog.Logger, notify func(Event)) (*TurnLoop, error) {
        layout, err := loadViewLayout(filepath.Join(agent.dir, viewLayoutFileName))
        if err != nil {
@@ -46,6 +47,10 @@ func newTurnLoop(agent *Agent, memory *Memory, subagents *Subagents, whatsapp *W
                running:   make(map[string]*SubagentRun),
        }
 
                running:   make(map[string]*SubagentRun),
        }
 
+       if agent.config.Parent != "" {
+               whatsapp = nil
+       }
+
        l.tools = &Toolbox{
                log:       l,
                chat:      memory,
        l.tools = &Toolbox{
                log:       l,
                chat:      memory,
@@ -386,7 +391,7 @@ func (l *TurnLoop) chain(ctx context.Context) error {
                        Model:        l.agent.config.Model,
                        Effort:       l.agent.config.Effort,
                        Instructions: instructions,
                        Model:        l.agent.config.Model,
                        Effort:       l.agent.config.Effort,
                        Instructions: instructions,
-                       Tools:        promptTools(),
+                       Tools:        l.agent.Tools(),
                },
                take: l.take,
        }
                },
                take: l.take,
        }