fix: include available tool names in "tool not found" error message

When the LLM calls a non-existent tool, the error message now lists all
available tools so the LLM can self-correct on the next iteration instead
of blindly guessing names (observed 7+ wasted iterations in heartbeat).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dj-oyu 2026-03-02 04:23:04 +09:00
parent 6ba86a7e90
commit 3827fa8942

View file

@ -82,11 +82,14 @@ func (r *ToolRegistry) ExecuteWithContext(
tool, ok := r.Get(name)
if !ok {
available := strings.Join(r.List(), ", ")
logger.ErrorCF("tool", "Tool not found",
map[string]any{
"tool": name,
})
return ErrorResult(fmt.Sprintf("tool %q not found", name)).WithError(fmt.Errorf("tool not found"))
return ErrorResult(fmt.Sprintf(
"tool %q not found. Available tools: %s", name, available,
)).WithError(fmt.Errorf("tool not found"))
}
// If tool implements ContextualTool, set context