AI agent self-diagnosis in tool invocation failures