Fix infinite loop in message tool and fix compilation error on main branch.

This commit is contained in:
stevef 2026-04-20 11:51:08 +02:00
parent b43b81162b
commit 02755f60d0
3 changed files with 7 additions and 8 deletions

View file

@ -102,13 +102,11 @@ func NewAgentInstance(
toolsRegistry.Register(tools.NewListDirTool(workspace, readRestrict, allowReadPaths)) toolsRegistry.Register(tools.NewListDirTool(workspace, readRestrict, allowReadPaths))
} }
if cfg.Tools.IsToolEnabled("exec") { if cfg.Tools.IsToolEnabled("exec") {
execTool, err := tools.NewExecToolWithDenyPaths(workspace, restrict, [][]*regexp.Regexp{allowReadPaths}, denyWritePaths, cfg) execTool, err := tools.NewExecToolWithConfig(workspace, restrict, cfg, allowReadPaths)
if err != nil { if err != nil {
logger.ErrorCF("agent", "Failed to initialize exec tool; continuing without exec", logger.ErrorCF("agent", "Failed to initialize exec tool; continuing without exec",
map[string]any{"error": err.Error()}) map[string]any{"error": err.Error()})
execTool = nil } else {
}
if execTool != nil {
toolsRegistry.Register(execTool) toolsRegistry.Register(execTool)
} }
} }

View file

@ -3693,8 +3693,8 @@ func TestProcessMessage_MessageToolPublishesOutboundWithTurnMetadata(t *testing.
if err != nil { if err != nil {
t.Fatalf("processMessage() error = %v", err) t.Fatalf("processMessage() error = %v", err)
} }
if response == "" { if response != "" {
t.Fatal("expected processMessage() to return a final loop response") t.Fatalf("expected empty loop response when tool handles delivery, got %q", response)
} }
select { select {

View file

@ -137,7 +137,8 @@ func (t *MessageTool) Execute(ctx context.Context, args map[string]any) *ToolRes
// Silent: user already received the message directly // Silent: user already received the message directly
return &ToolResult{ return &ToolResult{
ForLLM: fmt.Sprintf("Message sent to %s:%s", channel, chatID), ForLLM: fmt.Sprintf("Message sent to %s:%s", channel, chatID),
Silent: true, Silent: true,
ResponseHandled: true,
} }
} }