on main help sign in
fix(agent): fix minor bugs in coordinator and view tool (#2276)
262c74ehuaiyuWangh
internal/agent/coordinator.go+3−2
@@ -472,9 +472,10 @@ func (c *coordinator) buildTools(ctx context.Context, agent config.Agent) ([]fan
472 }
472 }
473 if len(tools) == 0 || slices.Contains(tools, tool.MCPToolName()) {
473 if len(tools) == 0 || slices.Contains(tools, tool.MCPToolName()) {
474 filteredTools = append(filteredTools, tool)
474 filteredTools = append(filteredTools, tool)
475+ break
475 }
476 }
477+ slog.Debug("MCP not allowed", "tool", tool.Name(), "agent", agent.Name)
476 }
478 }
477− slog.Debug("MCP not allowed", "tool", tool.Name(), "agent", agent.Name)
478 }
479 }
479 slices.SortFunc(filteredTools, func(a, b fantasy.AgentTool) int {
480 slices.SortFunc(filteredTools, func(a, b fantasy.AgentTool) int {
480 return strings.Compare(a.Info().Name, b.Info().Name)
481 return strings.Compare(a.Info().Name, b.Info().Name)
@@ -505,7 +506,7 @@ func (c *coordinator) buildAgentModels(ctx context.Context, isSubAgent bool) (Mo
505
506
506 smallProviderCfg, ok := c.cfg.Providers.Get(smallModelCfg.Provider)
507 smallProviderCfg, ok := c.cfg.Providers.Get(smallModelCfg.Provider)
507 if !ok {
508 if !ok {
508− return Model{}, Model{}, errors.New("large model provider not configured")
509+ return Model{}, Model{}, errors.New("small model provider not configured")
509 }
510 }
510
511
511 smallProvider, err := c.buildProvider(smallProviderCfg, smallModelCfg, true)
512 smallProvider, err := c.buildProvider(smallProviderCfg, smallModelCfg, true)
internal/agent/tools/view.go+3−3
@@ -186,13 +186,13 @@ func NewViewTool(
186
186
187 // Read the file content
187 // Read the file content
188 content, lineCount, err := readTextFile(filePath, params.Offset, params.Limit)
188 content, lineCount, err := readTextFile(filePath, params.Offset, params.Limit)
189+ if err != nil {
190+ return fantasy.ToolResponse{}, fmt.Errorf("error reading file: %w", err)
191+ }
189 isValidUt8 := utf8.ValidString(content)
192 isValidUt8 := utf8.ValidString(content)
190 if !isValidUt8 {
193 if !isValidUt8 {
191 return fantasy.NewTextErrorResponse("File content is not valid UTF-8"), nil
194 return fantasy.NewTextErrorResponse("File content is not valid UTF-8"), nil
192 }
195 }
193− if err != nil {
194− return fantasy.ToolResponse{}, fmt.Errorf("error reading file: %w", err)
195− }
196
196
197 notifyLSPs(ctx, lspManager, filePath)
197 notifyLSPs(ctx, lspManager, filePath)
198 output := "<file>\n"
198 output := "<file>\n"