on main help sign in
fix(agent): fix minor bugs in coordinator and view tool (#2276)

- Fix misleading error message: report "small model provider not configured" instead of "large" when the small model provider is missing - Fix error handling order in view tool: check readTextFile error before UTF-8 validation to avoid validating partial/empty content - Fix MCP tool filtering: move "MCP not allowed" log into correct branch and break after tool is added to prevent duplicate additions

commit262c74ef8c0bd5528be3562657ed1641d50b8f90 authorhuaiyuWangh <34158348+huaiyuWangh@users.noreply.github.com> dateTue 24 Feb 2026, 04:19 (8 months ago) parent6e019e9
2 files changed+6−5
internal/agent/coordinator.go+3−2 internal/agent/tools/view.go+3−3
internal/agent/coordinator.go+3−2
@@ -472,9 +472,10 @@ func (c *coordinator) buildTools(ctx context.Context, agent config.Agent) ([]fan
472472 }
473473 if len(tools) == 0 || slices.Contains(tools, tool.MCPToolName()) {
474474 filteredTools = append(filteredTools, tool)
475+ break
475476 }
477+ slog.Debug("MCP not allowed", "tool", tool.Name(), "agent", agent.Name)
476478 }
477− slog.Debug("MCP not allowed", "tool", tool.Name(), "agent", agent.Name)
478479 }
479480 slices.SortFunc(filteredTools, func(a, b fantasy.AgentTool) int {
480481 return strings.Compare(a.Info().Name, b.Info().Name)
@@ -505,7 +506,7 @@ func (c *coordinator) buildAgentModels(ctx context.Context, isSubAgent bool) (Mo
505506
506507 smallProviderCfg, ok := c.cfg.Providers.Get(smallModelCfg.Provider)
507508 if !ok {
508− return Model{}, Model{}, errors.New("large model provider not configured")
509+ return Model{}, Model{}, errors.New("small model provider not configured")
509510 }
510511
511512 smallProvider, err := c.buildProvider(smallProviderCfg, smallModelCfg, true)
internal/agent/tools/view.go+3−3
@@ -186,13 +186,13 @@ func NewViewTool(
186186
187187 // Read the file content
188188 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+ }
189192 isValidUt8 := utf8.ValidString(content)
190193 if !isValidUt8 {
191194 return fantasy.NewTextErrorResponse("File content is not valid UTF-8"), nil
192195 }
193− if err != nil {
194− return fantasy.ToolResponse{}, fmt.Errorf("error reading file: %w", err)
195− }
196196
197197 notifyLSPs(ctx, lspManager, filePath)
198198 output := "<file>\n"